Browse Source

Upgrade forum to the substrate 2.0 version

iorveth 4 years ago
parent
commit
eeaf3a0cfd
100 changed files with 3445 additions and 1941 deletions
  1. 378 175
      Cargo.lock
  2. 1 1
      README.md
  3. 1 1
      devops/git-hooks/pre-push
  4. 1 1
      joystream-node.Dockerfile
  5. 51 50
      node/Cargo.toml
  6. 2 2
      node/README.md
  7. 29 7
      node/src/chain_spec/mod.rs
  8. 44 10
      node/src/cli.rs
  9. 112 24
      node/src/command.rs
  10. 35 19
      node/src/node_rpc.rs
  11. 503 401
      node/src/service.rs
  12. 2 1
      query-node/indexer-tsconfig.json
  13. 22 8
      query-node/mappings/content-directory/content-dir-consts.ts
  14. 25 12
      query-node/mappings/content-directory/decode.ts
  15. 0 476
      query-node/mappings/content-directory/entity-helper.ts
  16. 397 0
      query-node/mappings/content-directory/entity/create.ts
  17. 89 34
      query-node/mappings/content-directory/entity/index.ts
  18. 108 0
      query-node/mappings/content-directory/entity/remove.ts
  19. 260 0
      query-node/mappings/content-directory/entity/update.ts
  20. 411 0
      query-node/mappings/content-directory/get-or-create.ts
  21. 201 94
      query-node/mappings/content-directory/transaction.ts
  22. 35 11
      query-node/mappings/types.ts
  23. 3 2
      query-node/package.json
  24. 56 18
      query-node/schema.graphql
  25. 21 0
      query-node/scripts/get-class-id-and-name.ts
  26. 7 7
      runtime-modules/common/Cargo.toml
  27. 4 3
      runtime-modules/common/src/currency.rs
  28. 2 2
      runtime-modules/common/src/lib.rs
  29. 3 3
      runtime-modules/common/src/origin.rs
  30. 10 10
      runtime-modules/content-directory/Cargo.toml
  31. 10 7
      runtime-modules/content-directory/src/lib.rs
  32. 7 6
      runtime-modules/content-directory/src/mock.rs
  33. 1 1
      runtime-modules/content-directory/src/permissions.rs
  34. 2 2
      runtime-modules/content-directory/src/schema/convert.rs
  35. 2 2
      runtime-modules/content-directory/src/schema/output.rs
  36. 12 12
      runtime-modules/content-working-group/Cargo.toml
  37. 15 17
      runtime-modules/content-working-group/src/lib.rs
  38. 12 8
      runtime-modules/content-working-group/src/mock.rs
  39. 19 19
      runtime-modules/content-working-group/src/tests.rs
  40. 10 10
      runtime-modules/forum/Cargo.toml
  41. 6 6
      runtime-modules/forum/misc/Cargo.lock
  42. 2 2
      runtime-modules/forum/misc/data-migration/Cargo.toml
  43. 9 9
      runtime-modules/forum/misc/data-migration/benches/data-migration.rs
  44. 3 3
      runtime-modules/forum/misc/data-migration/src/lib.rs
  45. 10 10
      runtime-modules/forum/misc/data-migration/src/mock.rs
  46. 6 6
      runtime-modules/forum/misc/forum-module/Cargo.lock
  47. 7 7
      runtime-modules/forum/src/lib.rs
  48. 36 36
      runtime-modules/forum/src/mock.rs
  49. 12 12
      runtime-modules/governance/Cargo.toml
  50. 17 14
      runtime-modules/governance/src/council.rs
  51. 32 33
      runtime-modules/governance/src/election.rs
  52. 9 5
      runtime-modules/governance/src/mock.rs
  53. 11 11
      runtime-modules/hiring/Cargo.toml
  54. 14 13
      runtime-modules/hiring/src/lib.rs
  55. 8 5
      runtime-modules/hiring/src/mock.rs
  56. 4 3
      runtime-modules/hiring/src/test/mod.rs
  57. 12 12
      runtime-modules/membership/Cargo.toml
  58. 8 8
      runtime-modules/membership/src/lib.rs
  59. 10 6
      runtime-modules/membership/src/mock.rs
  60. 7 7
      runtime-modules/memo/Cargo.toml
  61. 4 4
      runtime-modules/memo/src/lib.rs
  62. 15 15
      runtime-modules/proposals/codex/Cargo.toml
  63. 9 8
      runtime-modules/proposals/codex/src/lib.rs
  64. 2 2
      runtime-modules/proposals/codex/src/proposal_types/mod.rs
  65. 14 9
      runtime-modules/proposals/codex/src/tests/mock.rs
  66. 3 13
      runtime-modules/proposals/codex/src/tests/mod.rs
  67. 11 11
      runtime-modules/proposals/discussion/Cargo.toml
  68. 5 5
      runtime-modules/proposals/discussion/src/lib.rs
  69. 11 7
      runtime-modules/proposals/discussion/src/tests/mock.rs
  70. 2 2
      runtime-modules/proposals/discussion/src/tests/mod.rs
  71. 12 12
      runtime-modules/proposals/engine/Cargo.toml
  72. 14 14
      runtime-modules/proposals/engine/src/lib.rs
  73. 11 7
      runtime-modules/proposals/engine/src/tests/mock/mod.rs
  74. 1 1
      runtime-modules/proposals/engine/src/tests/mock/proposals.rs
  75. 9 4
      runtime-modules/proposals/engine/src/tests/mod.rs
  76. 5 4
      runtime-modules/proposals/engine/src/types/mod.rs
  77. 10 10
      runtime-modules/recurring-reward/Cargo.toml
  78. 3 3
      runtime-modules/recurring-reward/src/lib.rs
  79. 7 4
      runtime-modules/recurring-reward/src/mock/mod.rs
  80. 11 11
      runtime-modules/service-discovery/Cargo.toml
  81. 6 5
      runtime-modules/service-discovery/src/lib.rs
  82. 9 5
      runtime-modules/service-discovery/src/mock.rs
  83. 4 4
      runtime-modules/service-discovery/src/tests.rs
  84. 12 12
      runtime-modules/stake/Cargo.toml
  85. 10 6
      runtime-modules/stake/src/lib.rs
  86. 9 5
      runtime-modules/stake/src/mock.rs
  87. 12 12
      runtime-modules/storage/Cargo.toml
  88. 4 4
      runtime-modules/storage/src/data_directory.rs
  89. 2 2
      runtime-modules/storage/src/data_object_storage_registry.rs
  90. 2 2
      runtime-modules/storage/src/data_object_type_registry.rs
  91. 2 2
      runtime-modules/storage/src/tests/data_directory.rs
  92. 1 1
      runtime-modules/storage/src/tests/data_object_type_registry.rs
  93. 10 6
      runtime-modules/storage/src/tests/mock.rs
  94. 10 10
      runtime-modules/token-minting/Cargo.toml
  95. 3 3
      runtime-modules/token-minting/src/lib.rs
  96. 8 4
      runtime-modules/token-minting/src/mock.rs
  97. 11 11
      runtime-modules/versioned-store-permissions/Cargo.toml
  98. 24 18
      runtime-modules/versioned-store-permissions/src/lib.rs
  99. 8 6
      runtime-modules/versioned-store-permissions/src/mock.rs
  100. 13 13
      runtime-modules/versioned-store-permissions/src/tests.rs

File diff suppressed because it is too large
+ 378 - 175
Cargo.lock


+ 1 - 1
README.md

@@ -93,7 +93,7 @@ You can also run your our own joystream-node:
 
 
 ```sh
 ```sh
 git checkout master
 git checkout master
-WASM_BUILD_TOOLCHAIN=nightly-2020-05-23 cargo build --release
+WASM_BUILD_TOOLCHAIN=nightly-2020-10-06 cargo build --release
 ./target/release/joystream-node -- --pruning archive --chain testnets/joy-testnet-4.json
 ./target/release/joystream-node -- --pruning archive --chain testnets/joy-testnet-4.json
 ```
 ```
 
 

+ 1 - 1
devops/git-hooks/pre-push

@@ -1,7 +1,7 @@
 #!/bin/sh
 #!/bin/sh
 set -e
 set -e
 
 
-export WASM_BUILD_TOOLCHAIN=nightly-2020-05-23
+export WASM_BUILD_TOOLCHAIN=nightly-2020-10-06
 
 
 echo 'running clippy (rust linter)'
 echo 'running clippy (rust linter)'
 # When custom build.rs triggers wasm-build-runner-impl to build we get error:
 # When custom build.rs triggers wasm-build-runner-impl to build we get error:

+ 1 - 1
joystream-node.Dockerfile

@@ -5,7 +5,7 @@ COPY . /joystream
 
 
 # Build all cargo crates
 # Build all cargo crates
 # Ensure our tests and linter pass before actual build
 # Ensure our tests and linter pass before actual build
-ENV WASM_BUILD_TOOLCHAIN=nightly-2020-05-23
+ENV WASM_BUILD_TOOLCHAIN=nightly-2020-10-06
 RUN BUILD_DUMMY_WASM_BINARY=1 cargo clippy --release --all -- -D warnings && \
 RUN BUILD_DUMMY_WASM_BINARY=1 cargo clippy --release --all -- -D warnings && \
     cargo test --release --all && \
     cargo test --release --all && \
     cargo build --release
     cargo build --release

+ 51 - 50
node/Cargo.toml

@@ -3,7 +3,7 @@ authors = ['Joystream contributors']
 build = 'build.rs'
 build = 'build.rs'
 edition = '2018'
 edition = '2018'
 name = 'joystream-node'
 name = 'joystream-node'
-version = '3.4.1'
+version = '4.0.0'
 default-run = "joystream-node"
 default-run = "joystream-node"
 
 
 [[bin]]
 [[bin]]
@@ -17,79 +17,80 @@ crate-type = ["cdylib", "rlib"]
 # third-party dependencies
 # third-party dependencies
 serde = { version = "1.0.102", features = ["derive"] }
 serde = { version = "1.0.102", features = ["derive"] }
 futures = { version = "0.3.1", features = ["compat"] }
 futures = { version = "0.3.1", features = ["compat"] }
-jsonrpc-core = "14.2.0"
+jsonrpc-core = "15.0.0"
 structopt = { version = "0.3.8", optional = true}
 structopt = { version = "0.3.8", optional = true}
 serde_json = '1.0'
 serde_json = '1.0'
-codec = { package = "parity-scale-codec", version = "1.3.1" }
+codec = { package = "parity-scale-codec", version = "1.3.4" }
 hex = { package = "hex", version = "0.4.2" }
 hex = { package = "hex", version = "0.4.2" }
 
 
 # primitives
 # primitives
-sp-authority-discovery = { package = 'sp-authority-discovery', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sp-consensus-babe = { package = 'sp-consensus-babe', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sp-finality-grandpa = { package = 'sp-finality-grandpa', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sp-core = { package = 'sp-core', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sp-runtime = { package = 'sp-runtime', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sp-finality-tracker = { package = 'sp-finality-tracker', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sp-inherents = { package = 'sp-inherents', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sp-consensus = { package = 'sp-consensus', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sp-transaction-pool = { package = 'sp-transaction-pool', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sp-api = { package = 'sp-api', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sp-blockchain = { package = 'sp-blockchain', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sp-block-builder = { package = 'sp-block-builder', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
+sp-authority-discovery = { package = 'sp-authority-discovery', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sp-consensus-babe = { package = 'sp-consensus-babe', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sp-finality-grandpa = { package = 'sp-finality-grandpa', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sp-core = { package = 'sp-core', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sp-runtime = { package = 'sp-runtime', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sp-finality-tracker = { package = 'sp-finality-tracker', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sp-inherents = { package = 'sp-inherents', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sp-consensus = { package = 'sp-consensus', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sp-transaction-pool = { package = 'sp-transaction-pool', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sp-api = { package = 'sp-api', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sp-blockchain = { package = 'sp-blockchain', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sp-block-builder = { package = 'sp-block-builder', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
 
 
 # client dependencies
 # client dependencies
-sc-client-api = { package = 'sc-client-api', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sc-chain-spec = { package = 'sc-chain-spec', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sc-consensus = { package = 'sc-consensus', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sc-transaction-pool = { package = 'sc-transaction-pool', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sc-network = { package = 'sc-network', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sc-consensus-babe = { package = 'sc-consensus-babe', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sc-finality-grandpa = { package = 'sc-finality-grandpa', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sc-basic-authorship = { package = 'sc-basic-authorship', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sc-service = { package = 'sc-service', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sc-authority-discovery = { package = 'sc-authority-discovery', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sc-consensus-epochs = { package = 'sc-consensus-epochs', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sc-keystore = { package = 'sc-keystore', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sc-consensus-babe-rpc = { package = 'sc-consensus-babe-rpc', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sc-finality-grandpa-rpc = { package = 'sc-finality-grandpa-rpc', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sc-rpc-api = { package = 'sc-rpc-api', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sc-executor = { package = 'sc-executor', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
+sc-client-api = { package = 'sc-client-api', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sc-chain-spec = { package = 'sc-chain-spec', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sc-consensus = { package = 'sc-consensus', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sc-transaction-pool = { package = 'sc-transaction-pool', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sc-network = { package = 'sc-network', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sc-consensus-babe = { package = 'sc-consensus-babe', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sc-finality-grandpa = { package = 'sc-finality-grandpa', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sc-basic-authorship = { package = 'sc-basic-authorship', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sc-service = { package = 'sc-service', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sc-authority-discovery = { package = 'sc-authority-discovery', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sc-consensus-epochs = { package = 'sc-consensus-epochs', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sc-keystore = { package = 'sc-keystore', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sc-consensus-babe-rpc = { package = 'sc-consensus-babe-rpc', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sc-finality-grandpa-rpc = { package = 'sc-finality-grandpa-rpc', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sc-rpc-api = { package = 'sc-rpc-api', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sc-rpc = { package = 'sc-rpc', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sc-executor = { package = 'sc-executor', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
 
 
 # frame dependencies
 # frame dependencies
-pallet-im-online = { package = 'pallet-im-online', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-pallet-transaction-payment-rpc = { package = 'pallet-transaction-payment-rpc', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-substrate-frame-rpc-system = { package = 'substrate-frame-rpc-system', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-frame-benchmarking = { package = 'frame-benchmarking', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
+pallet-im-online = { package = 'pallet-im-online', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+pallet-transaction-payment-rpc = { package = 'pallet-transaction-payment-rpc', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+substrate-frame-rpc-system = { package = 'substrate-frame-rpc-system', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+frame-benchmarking = { package = 'frame-benchmarking', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
 
 
 # node-specific dependencies
 # node-specific dependencies
 node-runtime = { package= "joystream-node-runtime", path = "../runtime" }
 node-runtime = { package= "joystream-node-runtime", path = "../runtime" }
 
 
 # CLI-specific dependencies
 # CLI-specific dependencies
-sc-cli = { package = 'sc-cli', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', optional = true }
-frame-benchmarking-cli = { package = 'frame-benchmarking-cli', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', optional = true }
-node-inspect = { package = 'node-inspect', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', optional = true }
+sc-cli = { package = 'sc-cli', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca', optional = true }
+frame-benchmarking-cli = { package = 'frame-benchmarking-cli', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca', optional = true }
+node-inspect = { package = 'node-inspect', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca', optional = true }
 
 
 # WASM-specific dependencies
 # WASM-specific dependencies
 wasm-bindgen = { version = "0.2.57", optional = true }
 wasm-bindgen = { version = "0.2.57", optional = true }
 wasm-bindgen-futures = { version = "0.4.7", optional = true }
 wasm-bindgen-futures = { version = "0.4.7", optional = true }
-browser-utils = { package = 'substrate-browser-utils', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', optional = true}
+browser-utils = { package = 'substrate-browser-utils', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca', optional = true}
 
 
 [dev-dependencies]
 [dev-dependencies]
 tempfile = "3.1.0"
 tempfile = "3.1.0"
-sp-timestamp = { package = 'sp-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sp-keyring = { package = 'sp-keyring', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sc-consensus-babe = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', features = ["test-helpers"]}
-sc-service-test = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-frame-system = { package = 'frame-system', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-pallet-transaction-payment = { package = 'pallet-transaction-payment', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-pallet-grandpa = { package = 'pallet-grandpa', git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
+sp-timestamp = { package = 'sp-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sp-keyring = { package = 'sp-keyring', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+sc-consensus-babe = { git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca', features = ["test-helpers"]}
+sc-service-test = { git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+frame-system = { package = 'frame-system', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+pallet-transaction-payment = { package = 'pallet-transaction-payment', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
+pallet-grandpa = { package = 'pallet-grandpa', git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
 
 
 [build-dependencies]
 [build-dependencies]
 structopt = { version = "0.3.8", optional = true }
 structopt = { version = "0.3.8", optional = true }
-node-inspect = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', optional = true}
-sc-cli = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', optional = true}
-frame-benchmarking-cli = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', optional = true }
-substrate-build-script-utils = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', optional = true }
+node-inspect = { git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca', optional = true}
+sc-cli = { git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca', optional = true}
+frame-benchmarking-cli = { git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca', optional = true }
+substrate-build-script-utils = { git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca', optional = true }
 
 
 [features]
 [features]
 default = [ "cli" ]
 default = [ "cli" ]

+ 2 - 2
node/README.md

@@ -26,7 +26,7 @@ cd joystream/
 Compile the node and runtime:
 Compile the node and runtime:
 
 
 ```bash
 ```bash
-WASM_BUILD_TOOLCHAIN=nightly-2020-05-23 cargo build --release
+WASM_BUILD_TOOLCHAIN=nightly-2020-10-06 cargo build --release
 ```
 ```
 
 
 This produces the binary in `./target/release/joystream-node`
 This produces the binary in `./target/release/joystream-node`
@@ -79,7 +79,7 @@ If you are building a tagged release from `master` branch and want to install th
 This will install the executable `joystream-node` to your `~/.cargo/bin` folder, which you would normally have in your `$PATH` environment.
 This will install the executable `joystream-node` to your `~/.cargo/bin` folder, which you would normally have in your `$PATH` environment.
 
 
 ```bash
 ```bash
-WASM_BUILD_TOOLCHAIN=nightly-2020-05-23 cargo install joystream-node --path node/ --locked
+WASM_BUILD_TOOLCHAIN=nightly-2020-10-06 cargo install joystream-node --path node/ --locked
 ```
 ```
 
 
 Now you can run and connect to the testnet:
 Now you can run and connect to the testnet:

+ 29 - 7
node/src/chain_spec/mod.rs

@@ -29,13 +29,13 @@ use sp_runtime::traits::{IdentifyAccount, Verify};
 use sp_runtime::Perbill;
 use sp_runtime::Perbill;
 
 
 use node_runtime::{
 use node_runtime::{
-    membership, AuthorityDiscoveryConfig, BabeConfig, Balance, BalancesConfig,
+    membership, wasm_binary_unwrap, AuthorityDiscoveryConfig, BabeConfig, Balance, BalancesConfig,
     ContentDirectoryConfig, ContentDirectoryWorkingGroupConfig, ContentWorkingGroupConfig,
     ContentDirectoryConfig, ContentDirectoryWorkingGroupConfig, ContentWorkingGroupConfig,
     CouncilConfig, CouncilElectionConfig, DataDirectoryConfig, DataObjectStorageRegistryConfig,
     CouncilConfig, CouncilElectionConfig, DataDirectoryConfig, DataObjectStorageRegistryConfig,
     DataObjectTypeRegistryConfig, ElectionParameters, ForumConfig, ForumWorkingGroupConfig,
     DataObjectTypeRegistryConfig, ElectionParameters, ForumConfig, ForumWorkingGroupConfig,
     GrandpaConfig, ImOnlineConfig, MembersConfig, Moment, ProposalsCodexConfig, SessionConfig,
     GrandpaConfig, ImOnlineConfig, MembersConfig, Moment, ProposalsCodexConfig, SessionConfig,
     SessionKeys, Signature, StakerStatus, StakingConfig, StorageWorkingGroupConfig, SudoConfig,
     SessionKeys, Signature, StakerStatus, StakingConfig, StorageWorkingGroupConfig, SudoConfig,
-    SystemConfig, VersionedStoreConfig, VersionedStorePermissionsConfig, DAYS, WASM_BINARY,
+    SystemConfig, VersionedStoreConfig, VersionedStorePermissionsConfig, DAYS,
 };
 };
 
 
 // Exported to be used by chain-spec-builder
 // Exported to be used by chain-spec-builder
@@ -235,8 +235,8 @@ pub fn testnet_genesis(
     let default_text_constraint = node_runtime::working_group::default_text_constraint();
     let default_text_constraint = node_runtime::working_group::default_text_constraint();
 
 
     GenesisConfig {
     GenesisConfig {
-        system: Some(SystemConfig {
-            code: WASM_BINARY.to_vec(),
+        frame_system: Some(SystemConfig {
+            code: wasm_binary_unwrap().to_vec(),
             changes_trie_config: Default::default(),
             changes_trie_config: Default::default(),
         }),
         }),
         pallet_balances: Some(BalancesConfig {
         pallet_balances: Some(BalancesConfig {
@@ -402,7 +402,7 @@ pub fn testnet_genesis(
 #[cfg(test)]
 #[cfg(test)]
 pub(crate) mod tests {
 pub(crate) mod tests {
     use super::*;
     use super::*;
-    use crate::service::{new_full, new_light};
+    use crate::service::{new_full_base, new_light_base, NewFullBase};
     use sc_service_test;
     use sc_service_test;
 
 
     fn local_testnet_genesis_instant_single() -> GenesisConfig {
     fn local_testnet_genesis_instant_single() -> GenesisConfig {
@@ -478,8 +478,30 @@ pub(crate) mod tests {
     fn test_connectivity() {
     fn test_connectivity() {
         sc_service_test::connectivity(
         sc_service_test::connectivity(
             integration_test_config_with_two_authorities(),
             integration_test_config_with_two_authorities(),
-            |config| new_full(config),
-            |config| new_light(config),
+            |config| {
+                let NewFullBase {
+                    task_manager,
+                    client,
+                    network,
+                    transaction_pool,
+                    ..
+                } = new_full_base(config, |_, _| ())?;
+                Ok(sc_service_test::TestNetComponents::new(
+                    task_manager,
+                    client,
+                    network,
+                    transaction_pool,
+                ))
+            },
+            |config| {
+                let (keep_alive, _, client, network, transaction_pool) = new_light_base(config)?;
+                Ok(sc_service_test::TestNetComponents::new(
+                    keep_alive,
+                    client,
+                    network,
+                    transaction_pool,
+                ))
+            },
         );
         );
     }
     }
 }
 }

+ 44 - 10
node/src/cli.rs

@@ -1,20 +1,22 @@
-// Copyright 2019 Joystream Contributors
-// This file is part of Joystream node.
+// This file is part of Substrate.
 
 
-// Joystream node is free software: you can redistribute it and/or modify
+// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
 // it under the terms of the GNU General Public License as published by
 // the Free Software Foundation, either version 3 of the License, or
 // the Free Software Foundation, either version 3 of the License, or
 // (at your option) any later version.
 // (at your option) any later version.
 
 
-// Joystream node is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 // GNU General Public License for more details.
 // GNU General Public License for more details.
 
 
 // You should have received a copy of the GNU General Public License
 // You should have received a copy of the GNU General Public License
-// along with Joystream node.  If not, see <http://www.gnu.org/licenses/>.
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
 
 
-use sc_cli::RunCmd;
+use sc_cli::{KeySubcommand, RunCmd, SignCmd, VanityCmd, VerifyCmd};
 use structopt::StructOpt;
 use structopt::StructOpt;
 
 
 /// An overarching CLI command definition.
 /// An overarching CLI command definition.
@@ -31,9 +33,8 @@ pub struct Cli {
 /// Possible subcommands of the main binary.
 /// Possible subcommands of the main binary.
 #[derive(Debug, StructOpt)]
 #[derive(Debug, StructOpt)]
 pub enum Subcommand {
 pub enum Subcommand {
-    /// A set of base subcommands handled by `sc_cli`.
-    #[structopt(flatten)]
-    Base(sc_cli::Subcommand),
+    /// Key management cli utilities
+    Key(KeySubcommand),
 
 
     /// The custom inspect subcommmand for decoding blocks and extrinsics.
     /// The custom inspect subcommmand for decoding blocks and extrinsics.
     #[structopt(
     #[structopt(
@@ -45,4 +46,37 @@ pub enum Subcommand {
     /// The custom benchmark subcommmand benchmarking runtime pallets.
     /// The custom benchmark subcommmand benchmarking runtime pallets.
     #[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
     #[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
     Benchmark(frame_benchmarking_cli::BenchmarkCmd),
     Benchmark(frame_benchmarking_cli::BenchmarkCmd),
+
+    /// Verify a signature for a message, provided on STDIN, with a given (public or secret) key.
+    Verify(VerifyCmd),
+
+    /// Generate a seed that provides a vanity address.
+    Vanity(VanityCmd),
+
+    /// Sign a message, with a given (secret) key.
+    Sign(SignCmd),
+
+    /// Build a chain specification.
+    BuildSpec(sc_cli::BuildSpecCmd),
+
+    /// Build a chain specification with a light client sync state.
+    BuildSyncSpec(sc_cli::BuildSyncSpecCmd),
+
+    /// Validate blocks.
+    CheckBlock(sc_cli::CheckBlockCmd),
+
+    /// Export blocks.
+    ExportBlocks(sc_cli::ExportBlocksCmd),
+
+    /// Export the state of a given block into a chain spec.
+    ExportState(sc_cli::ExportStateCmd),
+
+    /// Import blocks.
+    ImportBlocks(sc_cli::ImportBlocksCmd),
+
+    /// Remove the whole chain.
+    PurgeChain(sc_cli::PurgeChainCmd),
+
+    /// Revert the chain to a previous state.
+    Revert(sc_cli::RevertCmd),
 }
 }

+ 112 - 24
node/src/command.rs

@@ -16,41 +16,45 @@
 
 
 use crate::cli::{Cli, Subcommand};
 use crate::cli::{Cli, Subcommand};
 use crate::node_executor;
 use crate::node_executor;
-use crate::node_rpc;
 use crate::{chain_spec, service};
 use crate::{chain_spec, service};
 
 
+use crate::service::{new_full_base, new_partial, NewFullBase};
 use node_executor::Executor;
 use node_executor::Executor;
 use node_runtime::{opaque::Block, RuntimeApi};
 use node_runtime::{opaque::Block, RuntimeApi};
-use sc_cli::{Result, SubstrateCli};
-use sc_finality_grandpa::{self as grandpa};
+use sc_cli::{ChainSpec, Result, Role, RuntimeVersion, SubstrateCli};
+use sc_service::PartialComponents;
 
 
 impl SubstrateCli for Cli {
 impl SubstrateCli for Cli {
-    fn impl_name() -> &'static str {
-        "Joystream Node"
+    fn impl_name() -> String {
+        "Joystream Node".into()
     }
     }
 
 
-    fn support_url() -> &'static str {
-        "https://www.joystream.org/"
+    fn support_url() -> String {
+        "https://www.joystream.org/".into()
     }
     }
 
 
     fn copyright_start_year() -> i32 {
     fn copyright_start_year() -> i32 {
         2019
         2019
     }
     }
 
 
-    fn executable_name() -> &'static str {
-        "joystream-node"
+    fn executable_name() -> String {
+        "joystream-node".into()
     }
     }
 
 
-    fn impl_version() -> &'static str {
-        env!("SUBSTRATE_CLI_IMPL_VERSION")
+    fn impl_version() -> String {
+        env!("SUBSTRATE_CLI_IMPL_VERSION").into()
     }
     }
 
 
-    fn description() -> &'static str {
-        env!("CARGO_PKG_DESCRIPTION")
+    fn description() -> String {
+        env!("CARGO_PKG_DESCRIPTION").into()
     }
     }
 
 
-    fn author() -> &'static str {
-        env!("CARGO_PKG_AUTHORS")
+    fn author() -> String {
+        env!("CARGO_PKG_AUTHORS").into()
+    }
+
+    fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
+        &node_runtime::VERSION
     }
     }
 
 
     fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
     fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
@@ -71,7 +75,10 @@ pub fn run() -> Result<()> {
     match &cli.subcommand {
     match &cli.subcommand {
         None => {
         None => {
             let runner = cli.create_runner(&cli.run)?;
             let runner = cli.create_runner(&cli.run)?;
-            runner.run_node(service::new_light, service::new_full, node_runtime::VERSION)
+            runner.run_node_until_exit(|config| match config.role {
+                Role::Light => service::new_light(config),
+                _ => service::new_full(config),
+            })
         }
         }
         Some(Subcommand::Inspect(cmd)) => {
         Some(Subcommand::Inspect(cmd)) => {
             let runner = cli.create_runner(cmd)?;
             let runner = cli.create_runner(cmd)?;
@@ -84,17 +91,98 @@ pub fn run() -> Result<()> {
 
 
                 runner.sync_run(|config| cmd.run::<Block, Executor>(config))
                 runner.sync_run(|config| cmd.run::<Block, Executor>(config))
             } else {
             } else {
-                println!(
-                    "Benchmarking wasn't enabled when building the node. \
+                Err("Benchmarking wasn't enabled when building the node. \
 				You can enable it with `--features runtime-benchmarks`."
 				You can enable it with `--features runtime-benchmarks`."
-                );
-                Ok(())
+                    .into())
             }
             }
         }
         }
-        Some(Subcommand::Base(subcommand)) => {
-            let runner = cli.create_runner(subcommand)?;
-
-            runner.run_subcommand(subcommand, |config| Ok(new_full_start!(config).0))
+        Some(Subcommand::Key(cmd)) => cmd.run(),
+        Some(Subcommand::Sign(cmd)) => cmd.run(),
+        Some(Subcommand::Verify(cmd)) => cmd.run(),
+        Some(Subcommand::Vanity(cmd)) => cmd.run(),
+        Some(Subcommand::BuildSpec(cmd)) => {
+            let runner = cli.create_runner(cmd)?;
+            runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
+        }
+        Some(Subcommand::BuildSyncSpec(cmd)) => {
+            let runner = cli.create_runner(cmd)?;
+            runner.async_run(|config| {
+                let chain_spec = config.chain_spec.cloned_box();
+                let network_config = config.network.clone();
+                let NewFullBase {
+                    task_manager,
+                    client,
+                    network_status_sinks,
+                    ..
+                } = new_full_base(config, |_, _| ())?;
+
+                Ok((
+                    cmd.run(chain_spec, network_config, client, network_status_sinks),
+                    task_manager,
+                ))
+            })
+        }
+        Some(Subcommand::CheckBlock(cmd)) => {
+            let runner = cli.create_runner(cmd)?;
+            runner.async_run(|config| {
+                let PartialComponents {
+                    client,
+                    task_manager,
+                    import_queue,
+                    ..
+                } = new_partial(&config)?;
+                Ok((cmd.run(client, import_queue), task_manager))
+            })
+        }
+        Some(Subcommand::ExportBlocks(cmd)) => {
+            let runner = cli.create_runner(cmd)?;
+            runner.async_run(|config| {
+                let PartialComponents {
+                    client,
+                    task_manager,
+                    ..
+                } = new_partial(&config)?;
+                Ok((cmd.run(client, config.database), task_manager))
+            })
+        }
+        Some(Subcommand::ExportState(cmd)) => {
+            let runner = cli.create_runner(cmd)?;
+            runner.async_run(|config| {
+                let PartialComponents {
+                    client,
+                    task_manager,
+                    ..
+                } = new_partial(&config)?;
+                Ok((cmd.run(client, config.chain_spec), task_manager))
+            })
+        }
+        Some(Subcommand::ImportBlocks(cmd)) => {
+            let runner = cli.create_runner(cmd)?;
+            runner.async_run(|config| {
+                let PartialComponents {
+                    client,
+                    task_manager,
+                    import_queue,
+                    ..
+                } = new_partial(&config)?;
+                Ok((cmd.run(client, import_queue), task_manager))
+            })
+        }
+        Some(Subcommand::PurgeChain(cmd)) => {
+            let runner = cli.create_runner(cmd)?;
+            runner.sync_run(|config| cmd.run(config.database))
+        }
+        Some(Subcommand::Revert(cmd)) => {
+            let runner = cli.create_runner(cmd)?;
+            runner.async_run(|config| {
+                let PartialComponents {
+                    client,
+                    task_manager,
+                    backend,
+                    ..
+                } = new_partial(&config)?;
+                Ok((cmd.run(client, backend), task_manager))
+            })
         }
         }
     }
     }
 }
 }

+ 35 - 19
node/src/node_rpc.rs

@@ -30,23 +30,24 @@
 
 
 #![warn(missing_docs)]
 #![warn(missing_docs)]
 
 
-use std::sync::Arc;
-
-use node_runtime::UncheckedExtrinsic;
 use node_runtime::{opaque::Block, AccountId, Balance, BlockNumber, Hash, Index};
 use node_runtime::{opaque::Block, AccountId, Balance, BlockNumber, Hash, Index};
 use sc_consensus_babe::{Config, Epoch};
 use sc_consensus_babe::{Config, Epoch};
 use sc_consensus_babe_rpc::BabeRpcHandler;
 use sc_consensus_babe_rpc::BabeRpcHandler;
 use sc_consensus_epochs::SharedEpochChanges;
 use sc_consensus_epochs::SharedEpochChanges;
-use sc_finality_grandpa::{SharedAuthoritySet, SharedVoterState};
+use sc_finality_grandpa::{
+    FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState,
+};
 use sc_finality_grandpa_rpc::GrandpaRpcHandler;
 use sc_finality_grandpa_rpc::GrandpaRpcHandler;
 use sc_keystore::KeyStorePtr;
 use sc_keystore::KeyStorePtr;
-use sc_rpc_api::DenyUnsafe;
+use sc_rpc::SubscriptionTaskExecutor;
+pub use sc_rpc_api::DenyUnsafe;
 use sp_api::ProvideRuntimeApi;
 use sp_api::ProvideRuntimeApi;
 use sp_block_builder::BlockBuilder;
 use sp_block_builder::BlockBuilder;
 use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
 use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
 use sp_consensus::SelectChain;
 use sp_consensus::SelectChain;
 use sp_consensus_babe::BabeApi;
 use sp_consensus_babe::BabeApi;
 use sp_transaction_pool::TransactionPool;
 use sp_transaction_pool::TransactionPool;
+use std::sync::Arc;
 
 
 /// Light client extra dependencies.
 /// Light client extra dependencies.
 pub struct LightDeps<C, F, P> {
 pub struct LightDeps<C, F, P> {
@@ -71,15 +72,21 @@ pub struct BabeDeps {
 }
 }
 
 
 /// Extra dependencies for GRANDPA
 /// Extra dependencies for GRANDPA
-pub struct GrandpaDeps {
+pub struct GrandpaDeps<B> {
     /// Voting round info.
     /// Voting round info.
     pub shared_voter_state: SharedVoterState,
     pub shared_voter_state: SharedVoterState,
     /// Authority set info.
     /// Authority set info.
     pub shared_authority_set: SharedAuthoritySet<Hash, BlockNumber>,
     pub shared_authority_set: SharedAuthoritySet<Hash, BlockNumber>,
+    /// Receives notifications about justification events from Grandpa.
+    pub justification_stream: GrandpaJustificationStream<Block>,
+    /// Executor to drive the subscription manager in the Grandpa RPC handler.
+    pub subscription_executor: SubscriptionTaskExecutor,
+    /// Finality proof provider.
+    pub finality_provider: Arc<FinalityProofProvider<B, Block>>,
 }
 }
 
 
 /// Full client dependencies.
 /// Full client dependencies.
-pub struct FullDeps<C, P, SC> {
+pub struct FullDeps<C, P, SC, B> {
     /// The client instance to use.
     /// The client instance to use.
     pub client: Arc<C>,
     pub client: Arc<C>,
     /// Transaction pool instance.
     /// Transaction pool instance.
@@ -91,26 +98,28 @@ pub struct FullDeps<C, P, SC> {
     /// BABE specific dependencies.
     /// BABE specific dependencies.
     pub babe: BabeDeps,
     pub babe: BabeDeps,
     /// GRANDPA specific dependencies.
     /// GRANDPA specific dependencies.
-    pub grandpa: GrandpaDeps,
+    pub grandpa: GrandpaDeps<B>,
 }
 }
 
 
+/// A IO handler that uses all Full RPC extensions.
+pub type IoHandler = jsonrpc_core::IoHandler<sc_rpc::Metadata>;
+
 /// Instantiate all Full RPC extensions.
 /// Instantiate all Full RPC extensions.
-pub fn create_full<C, P, M, SC>(deps: FullDeps<C, P, SC>) -> jsonrpc_core::IoHandler<M>
+pub fn create_full<C, P, SC, B>(
+    deps: FullDeps<C, P, SC, B>,
+) -> jsonrpc_core::IoHandler<sc_rpc_api::Metadata>
 where
 where
     C: ProvideRuntimeApi<Block>,
     C: ProvideRuntimeApi<Block>,
     C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,
     C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,
     C: Send + Sync + 'static,
     C: Send + Sync + 'static,
     C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
     C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
-    C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<
-        Block,
-        Balance,
-        UncheckedExtrinsic,
-    >,
+    C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
     C::Api: BabeApi<Block>,
     C::Api: BabeApi<Block>,
     C::Api: BlockBuilder<Block>,
     C::Api: BlockBuilder<Block>,
     P: TransactionPool + 'static,
     P: TransactionPool + 'static,
-    M: jsonrpc_core::Metadata + Default,
     SC: SelectChain<Block> + 'static,
     SC: SelectChain<Block> + 'static,
+    B: sc_client_api::Backend<Block> + Send + Sync + 'static,
+    B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,
 {
 {
     use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
     use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
     use substrate_frame_rpc_system::{FullSystem, SystemApi};
     use substrate_frame_rpc_system::{FullSystem, SystemApi};
@@ -124,6 +133,7 @@ where
         babe,
         babe,
         grandpa,
         grandpa,
     } = deps;
     } = deps;
+
     let BabeDeps {
     let BabeDeps {
         keystore,
         keystore,
         babe_config,
         babe_config,
@@ -132,6 +142,9 @@ where
     let GrandpaDeps {
     let GrandpaDeps {
         shared_voter_state,
         shared_voter_state,
         shared_authority_set,
         shared_authority_set,
+        justification_stream,
+        subscription_executor,
+        finality_provider,
     } = grandpa;
     } = grandpa;
 
 
     io.extend_with(SystemApi::to_delegate(FullSystem::new(
     io.extend_with(SystemApi::to_delegate(FullSystem::new(
@@ -139,9 +152,6 @@ where
         pool,
         pool,
         deny_unsafe,
         deny_unsafe,
     )));
     )));
-    // Making synchronous calls in light client freezes the browser currently,
-    // more context: https://github.com/paritytech/substrate/pull/3480
-    // These RPCs should use an asynchronous caller instead.
     io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(
     io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(
         client.clone(),
         client.clone(),
     )));
     )));
@@ -156,7 +166,13 @@ where
         ),
         ),
     ));
     ));
     io.extend_with(sc_finality_grandpa_rpc::GrandpaApi::to_delegate(
     io.extend_with(sc_finality_grandpa_rpc::GrandpaApi::to_delegate(
-        GrandpaRpcHandler::new(shared_authority_set, shared_voter_state),
+        GrandpaRpcHandler::new(
+            shared_authority_set,
+            shared_voter_state,
+            justification_stream,
+            subscription_executor,
+            finality_provider,
+        ),
     ));
     ));
 
 
     io
     io

File diff suppressed because it is too large
+ 503 - 401
node/src/service.rs


+ 2 - 1
query-node/indexer-tsconfig.json

@@ -14,7 +14,8 @@
     "baseUrl": ".",
     "baseUrl": ".",
     "paths": {
     "paths": {
       "@polkadot/types/augment": ["../../../types/augment-codec/augment-types.ts"]
       "@polkadot/types/augment": ["../../../types/augment-codec/augment-types.ts"]
-    }
+    },
+    "esModuleInterop": true
   },
   },
   "exclude": ["node_modules"]
   "exclude": ["node_modules"]
 }
 }

+ 22 - 8
query-node/mappings/content-directory/content-dir-consts.ts

@@ -4,13 +4,15 @@ import { IPropertyIdWithName } from '../types'
 export enum ContentDirectoryKnownClasses {
 export enum ContentDirectoryKnownClasses {
   CHANNEL = 'Channel',
   CHANNEL = 'Channel',
   CATEGORY = 'Category',
   CATEGORY = 'Category',
+  HTTPMEDIALOCATION = 'HttpMediaLocation',
+  JOYSTREAMMEDIALOCATION = 'JoystreamMediaLocation',
   KNOWNLICENSE = 'KnownLicense',
   KNOWNLICENSE = 'KnownLicense',
+  LANGUAGE = 'Language',
+  LICENSE = 'License',
+  MEDIALOCATION = 'MediaLocation',
   USERDEFINEDLICENSE = 'UserDefinedLicense',
   USERDEFINEDLICENSE = 'UserDefinedLicense',
-  JOYSTREAMMEDIALOCATION = 'JoystreamMediaLocation',
-  HTTPMEDIALOCATION = 'HttpMediaLocation',
-  VIDEOMEDIA = 'VideoMedia',
   VIDEO = 'Video',
   VIDEO = 'Video',
-  LANGUAGE = 'Language',
+  VIDEOMEDIA = 'VideoMedia',
   VIDEOMEDIAENCODING = 'VideoMediaEncoding',
   VIDEOMEDIAENCODING = 'VideoMediaEncoding',
 }
 }
 
 
@@ -18,13 +20,15 @@ export enum ContentDirectoryKnownClasses {
 export const contentDirectoryClassNamesWithId: { classId: number; name: string }[] = [
 export const contentDirectoryClassNamesWithId: { classId: number; name: string }[] = [
   { name: ContentDirectoryKnownClasses.CHANNEL, classId: 1 },
   { name: ContentDirectoryKnownClasses.CHANNEL, classId: 1 },
   { name: ContentDirectoryKnownClasses.CATEGORY, classId: 2 },
   { name: ContentDirectoryKnownClasses.CATEGORY, classId: 2 },
+  { name: ContentDirectoryKnownClasses.HTTPMEDIALOCATION, classId: 3 },
+  { name: ContentDirectoryKnownClasses.JOYSTREAMMEDIALOCATION, classId: 4 },
   { name: ContentDirectoryKnownClasses.KNOWNLICENSE, classId: 5 },
   { name: ContentDirectoryKnownClasses.KNOWNLICENSE, classId: 5 },
-  { name: ContentDirectoryKnownClasses.USERDEFINEDLICENSE, classId: 9 },
   { name: ContentDirectoryKnownClasses.LANGUAGE, classId: 6 },
   { name: ContentDirectoryKnownClasses.LANGUAGE, classId: 6 },
-  { name: ContentDirectoryKnownClasses.JOYSTREAMMEDIALOCATION, classId: 4 },
-  { name: ContentDirectoryKnownClasses.HTTPMEDIALOCATION, classId: 3 },
-  { name: ContentDirectoryKnownClasses.VIDEOMEDIA, classId: 11 },
+  { name: ContentDirectoryKnownClasses.LICENSE, classId: 7 },
+  { name: ContentDirectoryKnownClasses.MEDIALOCATION, classId: 8 },
+  { name: ContentDirectoryKnownClasses.USERDEFINEDLICENSE, classId: 9 },
   { name: ContentDirectoryKnownClasses.VIDEO, classId: 10 },
   { name: ContentDirectoryKnownClasses.VIDEO, classId: 10 },
+  { name: ContentDirectoryKnownClasses.VIDEOMEDIA, classId: 11 },
   { name: ContentDirectoryKnownClasses.VIDEOMEDIAENCODING, classId: 12 },
   { name: ContentDirectoryKnownClasses.VIDEOMEDIAENCODING, classId: 12 },
 ]
 ]
 
 
@@ -43,6 +47,11 @@ export const channelPropertyNamesWithId: IPropertyIdWithName = {
   6: 'language',
   6: 'language',
 }
 }
 
 
+export const licensePropertyNamesWithId: IPropertyIdWithName = {
+  0: 'knownLicense',
+  1: 'userDefinedLicense',
+}
+
 export const knownLicensePropertyNamesWIthId: IPropertyIdWithName = {
 export const knownLicensePropertyNamesWIthId: IPropertyIdWithName = {
   0: 'code',
   0: 'code',
   1: 'name',
   1: 'name',
@@ -59,6 +68,11 @@ export const userDefinedLicensePropertyNamesWithId: IPropertyIdWithName = {
   0: 'content',
   0: 'content',
 }
 }
 
 
+export const mediaLocationPropertyNamesWithId: IPropertyIdWithName = {
+  0: 'httpMediaLocation',
+  1: 'joystreamMediaLocation',
+}
+
 export const joystreamMediaLocationPropertyNamesWithId: IPropertyIdWithName = {
 export const joystreamMediaLocationPropertyNamesWithId: IPropertyIdWithName = {
   0: 'dataObjectId',
   0: 'dataObjectId',
 }
 }

+ 25 - 12
query-node/mappings/content-directory/decode.ts

@@ -6,11 +6,15 @@ import {
   IBatchOperation,
   IBatchOperation,
   ICreateEntityOperation,
   ICreateEntityOperation,
   IEntity,
   IEntity,
+  IReference,
 } from '../types'
 } from '../types'
+import Debug from 'debug'
 
 
 import { ParametrizedClassPropertyValue, UpdatePropertyValuesOperation } from '@joystream/types/content-directory'
 import { ParametrizedClassPropertyValue, UpdatePropertyValuesOperation } from '@joystream/types/content-directory'
 import { createType } from '@joystream/types'
 import { createType } from '@joystream/types'
 
 
+const debug = Debug('mappings:cd:decode')
+
 function stringIfyEntityId(event: SubstrateEvent): string {
 function stringIfyEntityId(event: SubstrateEvent): string {
   const { 1: entityId } = event.params
   const { 1: entityId } = event.params
   return entityId.value as string
   return entityId.value as string
@@ -20,16 +24,18 @@ function setProperties<T>({ extrinsic, blockNumber }: SubstrateEvent, propNamesW
   if (extrinsic === undefined) throw Error('Undefined extrinsic')
   if (extrinsic === undefined) throw Error('Undefined extrinsic')
 
 
   const { 3: newPropertyValues } = extrinsic!.args
   const { 3: newPropertyValues } = extrinsic!.args
-  const properties: { [key: string]: any } = {}
+  const properties: { [key: string]: any; reference?: IReference } = {}
 
 
   for (const [k, v] of Object.entries(newPropertyValues.value)) {
   for (const [k, v] of Object.entries(newPropertyValues.value)) {
     const propertyName = propNamesWithId[k]
     const propertyName = propNamesWithId[k]
-    const propertyValue = createType('InputPropertyValue', v as any)
-      .asType('Single')
-      .value.toJSON()
-    properties[propertyName] = propertyValue
+    const singlePropVal = createType('InputPropertyValue', v as any).asType('Single')
+    properties[propertyName] = singlePropVal.isOfType('Reference')
+      ? { entityId: singlePropVal.asType('Reference').toJSON(), existing: true }
+      : singlePropVal.value.toJSON()
   }
   }
   properties.version = blockNumber
   properties.version = blockNumber
+
+  debug(`Entity properties: ${JSON.stringify(properties)}`)
   return properties as T
   return properties as T
 }
 }
 
 
@@ -49,15 +55,15 @@ function getClassEntity(event: SubstrateEvent): IClassEntity {
  * @param propertyNamesWithId
  * @param propertyNamesWithId
  */
  */
 function setEntityPropertyValues<T>(properties: IProperty[], propertyNamesWithId: IPropertyIdWithName): T {
 function setEntityPropertyValues<T>(properties: IProperty[], propertyNamesWithId: IPropertyIdWithName): T {
-  const entityProperties: { [key: string]: any } = {}
+  const entityProperties: { [key: string]: any; reference?: IReference } = {}
 
 
   for (const [propId, propName] of Object.entries(propertyNamesWithId)) {
   for (const [propId, propName] of Object.entries(propertyNamesWithId)) {
     // get the property value by id
     // get the property value by id
-    const p = properties.find((p) => p.propertyId === propId)
-    const propertyValue = p ? p.value : undefined
-    entityProperties[propName] = propertyValue
+    const p = properties.find((p) => p.id === propId)
+    if (!p) continue
+    entityProperties[propName] = p.reference ? p.reference : p.value
   }
   }
-  // console.log(entityProperties);
+  // debug(`Entity properties ${JSON.stringify(entityProperties)}`)
   return entityProperties as T
   return entityProperties as T
 }
 }
 
 
@@ -70,20 +76,27 @@ function getEntityProperties(propertyValues: ParametrizedClassPropertyValue[]):
     const v = createType('ParametrizedPropertyValue', pv.value)
     const v = createType('ParametrizedPropertyValue', pv.value)
     const propertyId = pv.in_class_index.toJSON()
     const propertyId = pv.in_class_index.toJSON()
 
 
+    let reference
     let value
     let value
     if (v.isOfType('InputPropertyValue')) {
     if (v.isOfType('InputPropertyValue')) {
       const inputPropVal = v.asType('InputPropertyValue')
       const inputPropVal = v.asType('InputPropertyValue')
       value = inputPropVal.isOfType('Single')
       value = inputPropVal.isOfType('Single')
         ? inputPropVal.asType('Single').value.toJSON()
         ? inputPropVal.asType('Single').value.toJSON()
         : inputPropVal.asType('Vector').value.toJSON()
         : inputPropVal.asType('Vector').value.toJSON()
+
+      if (inputPropVal.isOfType('Single')) {
+        if (inputPropVal.asType('Single').isOfType('Reference')) {
+          reference = { entityId: value as number, existing: true }
+        }
+      }
     } else if (v.isOfType('InternalEntityJustAdded')) {
     } else if (v.isOfType('InternalEntityJustAdded')) {
-      // const inputPropVal = v.asType('InternalEntityJustAdded');
       value = v.asType('InternalEntityJustAdded').toJSON()
       value = v.asType('InternalEntityJustAdded').toJSON()
+      reference = { entityId: value as number, existing: false }
     } else {
     } else {
       // TODO: Add support for v.asType('InternalEntityVec')
       // TODO: Add support for v.asType('InternalEntityVec')
       throw Error('InternalEntityVec property type is not supported yet!')
       throw Error('InternalEntityVec property type is not supported yet!')
     }
     }
-    properties.push({ propertyId: `${propertyId}`, value })
+    properties.push({ id: `${propertyId}`, value, reference })
   })
   })
   return properties
   return properties
 }
 }

+ 0 - 476
query-node/mappings/content-directory/entity-helper.ts

@@ -1,476 +0,0 @@
-import { DB, SubstrateEvent } from '../../generated/indexer'
-import { Channel } from '../../generated/graphql-server/src/modules/channel/channel.model'
-import { Category } from '../../generated/graphql-server/src/modules/category/category.model'
-import { KnownLicense } from '../../generated/graphql-server/src/modules/known-license/known-license.model'
-import { UserDefinedLicense } from '../../generated/graphql-server/src/modules/user-defined-license/user-defined-license.model'
-import { JoystreamMediaLocation } from '../../generated/graphql-server/src/modules/joystream-media-location/joystream-media-location.model'
-import { HttpMediaLocation } from '../../generated/graphql-server/src/modules/http-media-location/http-media-location.model'
-import { VideoMedia } from '../../generated/graphql-server/src/modules/video-media/video-media.model'
-import { Video } from '../../generated/graphql-server/src/modules/video/video.model'
-import { Block, Network } from '../../generated/graphql-server/src/modules/block/block.model'
-import { Language } from '../../generated/graphql-server/src/modules/language/language.model'
-import { VideoMediaEncoding } from '../../generated/graphql-server/src/modules/video-media-encoding/video-media-encoding.model'
-import { ClassEntity } from '../../generated/graphql-server/src/modules/class-entity/class-entity.model'
-import { decode } from './decode'
-import {
-  CategoryPropertyNamesWithId,
-  channelPropertyNamesWithId,
-  httpMediaLocationPropertyNamesWithId,
-  joystreamMediaLocationPropertyNamesWithId,
-  knownLicensePropertyNamesWIthId,
-  languagePropertyNamesWIthId,
-  userDefinedLicensePropertyNamesWithId,
-  videoMediaEncodingPropertyNamesWithId,
-  videoPropertyNamesWithId,
-  contentDirectoryClassNamesWithId,
-  ContentDirectoryKnownClasses,
-} from './content-dir-consts'
-import {
-  ICategory,
-  IChannel,
-  ICreateEntityOperation,
-  IDBBlockId,
-  IEntity,
-  IHttpMediaLocation,
-  IJoystreamMediaLocation,
-  IKnownLicense,
-  ILanguage,
-  IUserDefinedLicense,
-  IVideo,
-  IVideoMedia,
-  IVideoMediaEncoding,
-  IWhereCond,
-} from '../types'
-
-async function createBlockOrGetFromDatabase(db: DB, blockNumber: number): Promise<Block> {
-  let b = await db.get(Block, { where: { block: blockNumber } })
-  if (b === undefined) {
-    // TODO: get timestamp from the event or extrinsic
-    b = new Block({ block: blockNumber, nework: Network.BABYLON, timestamp: 123 })
-    await db.save<Block>(b)
-  }
-  return b
-}
-
-async function createChannel({ db, block, id }: IDBBlockId, p: IChannel): Promise<void> {
-  // const { properties: p } = decode.channelEntity(event);
-  const channel = new Channel()
-
-  channel.version = block
-  channel.id = id
-  channel.title = p.title
-  channel.description = p.description
-  channel.isCurated = p.isCurated || false
-  channel.isPublic = p.isPublic
-  channel.coverPhotoUrl = p.coverPhotoURL
-  channel.avatarPhotoUrl = p.avatarPhotoURL
-  channel.languageId = p.language
-  channel.happenedIn = await createBlockOrGetFromDatabase(db, block)
-  await db.save(channel)
-}
-
-async function createCategory({ db, block, id }: IDBBlockId, p: ICategory): Promise<void> {
-  // const p = decode.categoryEntity(event);
-  const category = new Category()
-
-  category.id = id
-  category.name = p.name
-  category.description = p.description
-  category.version = block
-  category.happenedIn = await createBlockOrGetFromDatabase(db, block)
-  await db.save(category)
-}
-
-async function createKnownLicense({ db, block, id }: IDBBlockId, p: IKnownLicense): Promise<void> {
-  const knownLicence = new KnownLicense()
-
-  knownLicence.id = id
-  knownLicence.code = p.code
-  knownLicence.name = p.name
-  knownLicence.description = p.description
-  knownLicence.url = p.url
-  knownLicence.version = block
-  knownLicence.happenedIn = await createBlockOrGetFromDatabase(db, block)
-  await db.save(knownLicence)
-}
-
-async function createUserDefinedLicense({ db, block, id }: IDBBlockId, p: IUserDefinedLicense): Promise<void> {
-  const userDefinedLicense = new UserDefinedLicense()
-
-  userDefinedLicense.id = id
-  userDefinedLicense.content = p.content
-  userDefinedLicense.version = block
-  userDefinedLicense.happenedIn = await createBlockOrGetFromDatabase(db, block)
-  await db.save(userDefinedLicense)
-}
-
-async function createJoystreamMediaLocation({ db, block, id }: IDBBlockId, p: IJoystreamMediaLocation): Promise<void> {
-  const joyMediaLoc = new JoystreamMediaLocation()
-
-  joyMediaLoc.id = id
-  joyMediaLoc.dataObjectId = p.dataObjectId
-  joyMediaLoc.version = block
-  joyMediaLoc.happenedIn = await createBlockOrGetFromDatabase(db, block)
-  await db.save(joyMediaLoc)
-}
-
-async function createHttpMediaLocation({ db, block, id }: IDBBlockId, p: IHttpMediaLocation): Promise<void> {
-  const httpMediaLoc = new HttpMediaLocation()
-
-  httpMediaLoc.id = id
-  httpMediaLoc.url = p.url
-  httpMediaLoc.port = p.port
-  httpMediaLoc.version = block
-  httpMediaLoc.happenedIn = await createBlockOrGetFromDatabase(db, block)
-  await db.save(httpMediaLoc)
-}
-
-async function createVideoMedia({ db, block, id }: IDBBlockId, p: IVideoMedia): Promise<void> {
-  const videoMedia = new VideoMedia()
-
-  videoMedia.id = id
-  videoMedia.encodingId = p.encoding
-  videoMedia.locationId = p.location
-  videoMedia.pixelHeight = p.pixelHeight
-  videoMedia.pixelWidth = p.pixelWidth
-  videoMedia.size = p.size
-  videoMedia.version = block
-  videoMedia.happenedIn = await createBlockOrGetFromDatabase(db, block)
-  await db.save(videoMedia)
-}
-
-async function createVideo({ db, block, id }: IDBBlockId, p: IVideo): Promise<void> {
-  const video = new Video()
-
-  video.id = id
-  video.title = p.title
-  video.description = p.description
-  video.categoryId = p.category
-  video.channelId = p.channel
-  video.duration = p.duration
-  video.hasMarketing = p.hasMarketing
-  // TODO: needs to be handled correctly, from runtime CurationStatus is coming
-  video.isCurated = p.isCurated || true
-  video.isExplicit = p.isExplicit
-  video.isPublic = p.isPublic
-  video.languageId = p.language
-  video.licenseId = p.license
-  video.videoMediaId = p.media
-  video.publishedBeforeJoystream = p.publishedBeforeJoystream
-  video.skippableIntroDuration = p.skippableIntroDuration
-  video.thumbnailUrl = p.thumbnailURL
-  video.version = block
-  video.happenedIn = await createBlockOrGetFromDatabase(db, block)
-  await db.save<Video>(video)
-}
-
-async function createLanguage({ db, block, id }: IDBBlockId, p: ILanguage): Promise<void> {
-  const language = new Language()
-  language.id = id
-  language.name = p.name
-  language.code = p.code
-  language.version = block
-  language.happenedIn = await createBlockOrGetFromDatabase(db, block)
-
-  await db.save<Language>(language)
-}
-
-async function createVideoMediaEncoding({ db, block, id }: IDBBlockId, p: IVideoMediaEncoding): Promise<void> {
-  const encoding = new VideoMediaEncoding()
-
-  encoding.id = id
-  encoding.name = p.name
-  encoding.version = block
-  // happenedIn is not defined in the graphql schema!
-  // encoding.happenedIn = await createBlockOrGetFromDatabase(db, block)
-  await db.save<VideoMediaEncoding>(encoding)
-}
-
-async function batchCreateClassEntities(db: DB, block: number, operations: ICreateEntityOperation[]): Promise<void> {
-  // Create entities before adding schema support
-  operations.map(async ({ classId }, index) => {
-    const c = new ClassEntity()
-    c.id = index.toString()
-    c.classId = classId
-    c.version = block
-    c.happenedIn = await createBlockOrGetFromDatabase(db, block)
-    await db.save<ClassEntity>(c)
-  })
-}
-
-async function getClassName(
-  db: DB,
-  entity: IEntity,
-  createEntityOperations: ICreateEntityOperation[]
-): Promise<string | undefined> {
-  const { entityId, indexOf } = entity
-  if (entityId === undefined && indexOf === undefined) {
-    throw Error(`Can not determine class of the entity`)
-  }
-
-  let classId: number | undefined
-  // Is newly created entity in the same transaction
-  if (indexOf !== undefined) {
-    classId = createEntityOperations[indexOf].classId
-  } else {
-    const ce = await db.get(ClassEntity, { where: { id: entityId } })
-    if (ce === undefined) console.log(`Class not found for the entity: ${entityId}`)
-    classId = ce ? ce.classId : undefined
-  }
-
-  const c = contentDirectoryClassNamesWithId.find((c) => c.classId === classId)
-  // TODO: stop execution, class should be created before entity creation
-  if (c === undefined) console.log(`Not recognized class id: ${classId}`)
-  return c ? c.name : undefined
-}
-
-async function removeChannel(db: DB, where: IWhereCond): Promise<void> {
-  const record = await db.get(Channel, where)
-  if (record === undefined) throw Error(`Channel not found`)
-  await db.remove<Channel>(record)
-}
-async function removeCategory(db: DB, where: IWhereCond): Promise<void> {
-  const record = await db.get(Category, where)
-  if (record === undefined) throw Error(`Category not found`)
-  await db.remove<Category>(record)
-}
-async function removeVideoMedia(db: DB, where: IWhereCond): Promise<void> {
-  const record = await db.get(VideoMedia, where)
-  if (record === undefined) throw Error(`VideoMedia not found`)
-  await db.remove<VideoMedia>(record)
-}
-async function removeVideo(db: DB, where: IWhereCond): Promise<void> {
-  const record = await db.get(Video, where)
-  if (record === undefined) throw Error(`Video not found`)
-  await db.remove<Video>(record)
-}
-async function removeUserDefinedLicense(db: DB, where: IWhereCond): Promise<void> {
-  const record = await db.get(UserDefinedLicense, where)
-  if (record === undefined) throw Error(`UserDefinedLicense not found`)
-  await db.remove<UserDefinedLicense>(record)
-}
-async function removeKnownLicense(db: DB, where: IWhereCond): Promise<void> {
-  const record = await db.get(KnownLicense, where)
-  if (record === undefined) throw Error(`KnownLicense not found`)
-  await db.remove<KnownLicense>(record)
-}
-async function removeHttpMediaLocation(db: DB, where: IWhereCond): Promise<void> {
-  const record = await db.get(HttpMediaLocation, where)
-  if (record === undefined) throw Error(`HttpMediaLocation not found`)
-  await db.remove<HttpMediaLocation>(record)
-}
-async function removeJoystreamMediaLocation(db: DB, where: IWhereCond): Promise<void> {
-  const record = await db.get(JoystreamMediaLocation, where)
-  if (record === undefined) throw Error(`JoystreamMediaLocation not found`)
-  await db.remove<JoystreamMediaLocation>(record)
-}
-async function removeLanguage(db: DB, where: IWhereCond): Promise<void> {
-  const record = await db.get(Language, where)
-  if (record === undefined) throw Error(`Language not found`)
-  await db.remove<Language>(record)
-}
-async function removeVideoMediaEncoding(db: DB, where: IWhereCond): Promise<void> {
-  const record = await db.get(VideoMediaEncoding, where)
-  if (record === undefined) throw Error(`Language not found`)
-  await db.remove<VideoMediaEncoding>(record)
-}
-
-// ========Entity property value updates========
-
-async function updateCategoryEntityPropertyValues(db: DB, where: IWhereCond, props: ICategory): Promise<void> {
-  const record = await db.get(Category, where)
-  if (record === undefined) throw Error(`Entity not found: ${where.where.id}`)
-  Object.assign(record, props)
-  await db.save<Category>(record)
-}
-async function updateChannelEntityPropertyValues(db: DB, where: IWhereCond, props: IChannel): Promise<void> {
-  const record = await db.get(Channel, where)
-  if (record === undefined) throw Error(`Entity not found: ${where.where.id}`)
-  Object.assign(record, props)
-  await db.save<Channel>(record)
-}
-async function updateVideoMediaEntityPropertyValues(db: DB, where: IWhereCond, props: IVideoMedia): Promise<void> {
-  const record = await db.get(VideoMedia, where)
-  if (record === undefined) throw Error(`Entity not found: ${where.where.id}`)
-  Object.assign(record, props)
-  await db.save<VideoMedia>(record)
-}
-async function updateVideoEntityPropertyValues(db: DB, where: IWhereCond, props: IVideo): Promise<void> {
-  const record = await db.get(Video, where)
-  if (record === undefined) throw Error(`Entity not found: ${where.where.id}`)
-  Object.assign(record, props)
-  await db.save<Video>(record)
-}
-async function updateUserDefinedLicenseEntityPropertyValues(
-  db: DB,
-  where: IWhereCond,
-  props: IUserDefinedLicense
-): Promise<void> {
-  const record = await db.get(UserDefinedLicense, where)
-  if (record === undefined) throw Error(`Entity not found: ${where.where.id}`)
-  Object.assign(record, props)
-  await db.save<UserDefinedLicense>(record)
-}
-async function updateKnownLicenseEntityPropertyValues(db: DB, where: IWhereCond, props: IKnownLicense): Promise<void> {
-  const record = await db.get(KnownLicense, where)
-  if (record === undefined) throw Error(`Entity not found: ${where.where.id}`)
-  Object.assign(record, props)
-  await db.save<KnownLicense>(record)
-}
-async function updateHttpMediaLocationEntityPropertyValues(
-  db: DB,
-  where: IWhereCond,
-  props: IHttpMediaLocation
-): Promise<void> {
-  const record = await db.get(HttpMediaLocation, where)
-  if (record === undefined) throw Error(`Entity not found: ${where.where.id}`)
-  Object.assign(record, props)
-  await db.save<HttpMediaLocation>(record)
-}
-async function updateJoystreamMediaLocationEntityPropertyValues(
-  db: DB,
-  where: IWhereCond,
-  props: IJoystreamMediaLocation
-): Promise<void> {
-  const record = await db.get(JoystreamMediaLocation, where)
-  if (record === undefined) throw Error(`Entity not found: ${where.where.id}`)
-  Object.assign(record, props)
-  await db.save<JoystreamMediaLocation>(record)
-}
-async function updateLanguageEntityPropertyValues(db: DB, where: IWhereCond, props: ILanguage): Promise<void> {
-  const record = await db.get(Language, where)
-  if (record === undefined) throw Error(`Entity not found: ${where.where.id}`)
-  Object.assign(record, props)
-  await db.save<Language>(record)
-}
-async function updateVideoMediaEncodingEntityPropertyValues(
-  db: DB,
-  where: IWhereCond,
-  props: IVideoMediaEncoding
-): Promise<void> {
-  const record = await db.get(VideoMediaEncoding, where)
-  if (record === undefined) throw Error(`Entity not found: ${where.where.id}`)
-  Object.assign(record, props)
-  await db.save<VideoMediaEncoding>(record)
-}
-
-async function updateEntityPropertyValues(
-  db: DB,
-  event: SubstrateEvent,
-  where: IWhereCond,
-  className: string
-): Promise<void> {
-  switch (className) {
-    case ContentDirectoryKnownClasses.CHANNEL:
-      updateChannelEntityPropertyValues(db, where, decode.setProperties<IChannel>(event, channelPropertyNamesWithId))
-      break
-
-    case ContentDirectoryKnownClasses.CATEGORY:
-      await updateCategoryEntityPropertyValues(
-        db,
-        where,
-        decode.setProperties<ICategory>(event, CategoryPropertyNamesWithId)
-      )
-      break
-
-    case ContentDirectoryKnownClasses.KNOWNLICENSE:
-      await updateKnownLicenseEntityPropertyValues(
-        db,
-        where,
-        decode.setProperties<IKnownLicense>(event, knownLicensePropertyNamesWIthId)
-      )
-      break
-
-    case ContentDirectoryKnownClasses.USERDEFINEDLICENSE:
-      await updateUserDefinedLicenseEntityPropertyValues(
-        db,
-        where,
-        decode.setProperties<IUserDefinedLicense>(event, userDefinedLicensePropertyNamesWithId)
-      )
-      break
-
-    case ContentDirectoryKnownClasses.JOYSTREAMMEDIALOCATION:
-      await updateJoystreamMediaLocationEntityPropertyValues(
-        db,
-        where,
-        decode.setProperties<IJoystreamMediaLocation>(event, joystreamMediaLocationPropertyNamesWithId)
-      )
-      break
-
-    case ContentDirectoryKnownClasses.HTTPMEDIALOCATION:
-      await updateHttpMediaLocationEntityPropertyValues(
-        db,
-        where,
-        decode.setProperties<IHttpMediaLocation>(event, httpMediaLocationPropertyNamesWithId)
-      )
-      break
-
-    case ContentDirectoryKnownClasses.VIDEOMEDIA:
-      await updateVideoMediaEntityPropertyValues(
-        db,
-        where,
-        decode.setProperties<IVideoMedia>(event, videoPropertyNamesWithId)
-      )
-      break
-
-    case ContentDirectoryKnownClasses.VIDEO:
-      await updateVideoEntityPropertyValues(db, where, decode.setProperties<IVideo>(event, videoPropertyNamesWithId))
-      break
-
-    case ContentDirectoryKnownClasses.LANGUAGE:
-      await updateLanguageEntityPropertyValues(
-        db,
-        where,
-        decode.setProperties<ILanguage>(event, languagePropertyNamesWIthId)
-      )
-      break
-
-    case ContentDirectoryKnownClasses.VIDEOMEDIAENCODING:
-      await updateVideoMediaEncodingEntityPropertyValues(
-        db,
-        where,
-        decode.setProperties<IVideoMediaEncoding>(event, videoMediaEncodingPropertyNamesWithId)
-      )
-      break
-
-    default:
-      throw new Error(`Unknown class name: ${className}`)
-  }
-}
-
-export {
-  createCategory,
-  createChannel,
-  createVideoMedia,
-  createVideo,
-  createUserDefinedLicense,
-  createKnownLicense,
-  createHttpMediaLocation,
-  createJoystreamMediaLocation,
-  createLanguage,
-  createVideoMediaEncoding,
-  removeCategory,
-  removeChannel,
-  removeVideoMedia,
-  removeVideo,
-  removeUserDefinedLicense,
-  removeKnownLicense,
-  removeHttpMediaLocation,
-  removeJoystreamMediaLocation,
-  removeLanguage,
-  removeVideoMediaEncoding,
-  createBlockOrGetFromDatabase,
-  batchCreateClassEntities,
-  getClassName,
-  updateCategoryEntityPropertyValues,
-  updateChannelEntityPropertyValues,
-  updateVideoMediaEntityPropertyValues,
-  updateVideoEntityPropertyValues,
-  updateUserDefinedLicenseEntityPropertyValues,
-  updateHttpMediaLocationEntityPropertyValues,
-  updateJoystreamMediaLocationEntityPropertyValues,
-  updateKnownLicenseEntityPropertyValues,
-  updateLanguageEntityPropertyValues,
-  updateVideoMediaEncodingEntityPropertyValues,
-  updateEntityPropertyValues,
-}

+ 397 - 0
query-node/mappings/content-directory/entity/create.ts

@@ -0,0 +1,397 @@
+import { DB } from '../../../generated/indexer'
+import { Channel } from '../../../generated/graphql-server/src/modules/channel/channel.model'
+import { Category } from '../../../generated/graphql-server/src/modules/category/category.model'
+import { KnownLicense } from '../../../generated/graphql-server/src/modules/known-license/known-license.model'
+import { UserDefinedLicense } from '../../../generated/graphql-server/src/modules/user-defined-license/user-defined-license.model'
+import { JoystreamMediaLocation } from '../../../generated/graphql-server/src/modules/joystream-media-location/joystream-media-location.model'
+import { HttpMediaLocation } from '../../../generated/graphql-server/src/modules/http-media-location/http-media-location.model'
+import { VideoMedia } from '../../../generated/graphql-server/src/modules/video-media/video-media.model'
+import { Video } from '../../../generated/graphql-server/src/modules/video/video.model'
+import { Block, Network } from '../../../generated/graphql-server/src/modules/block/block.model'
+import { Language } from '../../../generated/graphql-server/src/modules/language/language.model'
+import { VideoMediaEncoding } from '../../../generated/graphql-server/src/modules/video-media-encoding/video-media-encoding.model'
+import { ClassEntity } from '../../../generated/graphql-server/src/modules/class-entity/class-entity.model'
+import { License } from '../../../generated/graphql-server/src/modules/license/license.model'
+import { MediaLocation } from '../../../generated/graphql-server/src/modules/media-location/media-location.model'
+
+import { contentDirectoryClassNamesWithId } from '../content-dir-consts'
+import {
+  ClassEntityMap,
+  ICategory,
+  IChannel,
+  ICreateEntityOperation,
+  IDBBlockId,
+  IEntity,
+  IHttpMediaLocation,
+  IJoystreamMediaLocation,
+  IKnownLicense,
+  ILanguage,
+  ILicense,
+  IMediaLocation,
+  IUserDefinedLicense,
+  IVideo,
+  IVideoMedia,
+  IVideoMediaEncoding,
+} from '../../types'
+import { getOrCreate } from '../get-or-create'
+import BN from 'bn.js'
+
+async function createBlockOrGetFromDatabase(db: DB, blockNumber: number): Promise<Block> {
+  let b = await db.get(Block, { where: { block: blockNumber } })
+  if (b === undefined) {
+    // TODO: get timestamp from the event or extrinsic
+    b = new Block({ block: blockNumber, network: Network.BABYLON, timestamp: new BN(Date.now()) })
+    await db.save<Block>(b)
+  }
+  return b
+}
+
+async function createChannel(
+  { db, block, id }: IDBBlockId,
+  classEntityMap: ClassEntityMap,
+  p: IChannel,
+  nextEntityIdBeforeTransaction: number
+): Promise<Channel> {
+  const record = await db.get(Channel, { where: { id } })
+  if (record) return record
+
+  const channel = new Channel()
+
+  channel.version = block
+  channel.id = id
+  channel.title = p.title
+  channel.description = p.description
+  channel.isCurated = p.isCurated || false
+  channel.isPublic = p.isPublic
+  channel.coverPhotoUrl = p.coverPhotoURL
+  channel.avatarPhotoUrl = p.avatarPhotoURL
+
+  channel.happenedIn = await createBlockOrGetFromDatabase(db, block)
+  const { language } = p
+  if (language !== undefined) {
+    channel.language = await getOrCreate.language(
+      { db, block, id },
+      classEntityMap,
+      language,
+      nextEntityIdBeforeTransaction
+    )
+  }
+  await db.save(channel)
+  return channel
+}
+
+async function createCategory({ db, block, id }: IDBBlockId, p: ICategory): Promise<Category> {
+  const record = await db.get(Category, { where: { id } })
+  if (record) return record
+
+  const category = new Category()
+
+  category.id = id
+  category.name = p.name
+  category.description = p.description
+  category.version = block
+  category.happenedIn = await createBlockOrGetFromDatabase(db, block)
+  await db.save(category)
+  return category
+}
+
+async function createKnownLicense({ db, block, id }: IDBBlockId, p: IKnownLicense): Promise<KnownLicense> {
+  const record = await db.get(KnownLicense, { where: { id } })
+  if (record) return record
+
+  const knownLicence = new KnownLicense()
+
+  knownLicence.id = id
+  knownLicence.code = p.code
+  knownLicence.name = p.name
+  knownLicence.description = p.description
+  knownLicence.url = p.url
+  knownLicence.version = block
+  knownLicence.happenedIn = await createBlockOrGetFromDatabase(db, block)
+  await db.save(knownLicence)
+  return knownLicence
+}
+
+async function createUserDefinedLicense(
+  { db, block, id }: IDBBlockId,
+  p: IUserDefinedLicense
+): Promise<UserDefinedLicense> {
+  const record = await db.get(UserDefinedLicense, { where: { id } })
+  if (record) return record
+
+  const userDefinedLicense = new UserDefinedLicense()
+
+  userDefinedLicense.id = id
+  userDefinedLicense.content = p.content
+  userDefinedLicense.version = block
+  userDefinedLicense.happenedIn = await createBlockOrGetFromDatabase(db, block)
+  await db.save<UserDefinedLicense>(userDefinedLicense)
+  return userDefinedLicense
+}
+
+async function createJoystreamMediaLocation(
+  { db, block, id }: IDBBlockId,
+  p: IJoystreamMediaLocation
+): Promise<JoystreamMediaLocation> {
+  const record = await db.get(JoystreamMediaLocation, { where: { id } })
+  if (record) return record
+
+  const joyMediaLoc = new JoystreamMediaLocation()
+
+  joyMediaLoc.id = id
+  joyMediaLoc.dataObjectId = p.dataObjectId
+  joyMediaLoc.version = block
+  joyMediaLoc.happenedIn = await createBlockOrGetFromDatabase(db, block)
+  await db.save(joyMediaLoc)
+  return joyMediaLoc
+}
+
+async function createHttpMediaLocation(
+  { db, block, id }: IDBBlockId,
+  p: IHttpMediaLocation
+): Promise<HttpMediaLocation> {
+  const record = await db.get(HttpMediaLocation, { where: { id } })
+  if (record) return record
+
+  const httpMediaLoc = new HttpMediaLocation()
+
+  httpMediaLoc.id = id
+  httpMediaLoc.url = p.url
+  httpMediaLoc.port = p.port
+  httpMediaLoc.version = block
+  httpMediaLoc.happenedIn = await createBlockOrGetFromDatabase(db, block)
+  await db.save(httpMediaLoc)
+  return httpMediaLoc
+}
+
+async function createVideoMedia(
+  { db, block, id }: IDBBlockId,
+  classEntityMap: ClassEntityMap,
+  p: IVideoMedia,
+  nextEntityIdBeforeTransaction: number
+): Promise<VideoMedia> {
+  const videoMedia = new VideoMedia()
+
+  videoMedia.id = id
+  videoMedia.pixelHeight = p.pixelHeight
+  videoMedia.pixelWidth = p.pixelWidth
+  videoMedia.size = p.size
+  videoMedia.version = block
+  const { encoding, location } = p
+  if (encoding !== undefined) {
+    videoMedia.encoding = await getOrCreate.videoMediaEncoding(
+      { db, block, id },
+      classEntityMap,
+      encoding,
+      nextEntityIdBeforeTransaction
+    )
+  }
+  if (location !== undefined) {
+    videoMedia.location = await getOrCreate.mediaLocation(
+      { db, block, id },
+      classEntityMap,
+      location,
+      nextEntityIdBeforeTransaction
+    )
+  }
+
+  videoMedia.happenedIn = await createBlockOrGetFromDatabase(db, block)
+  await db.save(videoMedia)
+  return videoMedia
+}
+
+async function createVideo(
+  { db, block, id }: IDBBlockId,
+  classEntityMap: ClassEntityMap,
+  p: IVideo,
+  nextEntityIdBeforeTransaction: number
+): Promise<Video> {
+  const record = await db.get(Video, { where: { id } })
+  if (record) return record
+
+  const video = new Video()
+
+  video.id = id
+  video.title = p.title
+  video.description = p.description
+  video.duration = p.duration
+  video.hasMarketing = p.hasMarketing
+  // TODO: needs to be handled correctly, from runtime CurationStatus is coming
+  video.isCurated = p.isCurated || true
+  video.isExplicit = p.isExplicit
+  video.isPublic = p.isPublic
+  video.publishedBeforeJoystream = p.publishedBeforeJoystream
+  video.skippableIntroDuration = p.skippableIntroDuration
+  video.thumbnailUrl = p.thumbnailURL
+  video.version = block
+
+  const { language, license, category, channel, media } = p
+  if (language !== undefined) {
+    video.language = await getOrCreate.language(
+      { db, block, id },
+      classEntityMap,
+      language,
+      nextEntityIdBeforeTransaction
+    )
+  }
+  if (license !== undefined) {
+    video.license = await getOrCreate.license({ db, block, id }, classEntityMap, license, nextEntityIdBeforeTransaction)
+  }
+  if (category !== undefined) {
+    video.category = await getOrCreate.category(
+      { db, block, id },
+      classEntityMap,
+      category,
+      nextEntityIdBeforeTransaction
+    )
+  }
+  if (channel !== undefined) {
+    video.channel = await getOrCreate.channel({ db, block, id }, classEntityMap, channel, nextEntityIdBeforeTransaction)
+  }
+  if (media !== undefined) {
+    video.media = await getOrCreate.videoMedia({ db, block, id }, classEntityMap, media, nextEntityIdBeforeTransaction)
+  }
+
+  video.happenedIn = await createBlockOrGetFromDatabase(db, block)
+  await db.save<Video>(video)
+  return video
+}
+
+async function createLanguage({ db, block, id }: IDBBlockId, p: ILanguage): Promise<Language> {
+  const record = await db.get(Language, { where: { id } })
+  if (record) return record
+
+  const language = new Language()
+  language.id = id
+  language.name = p.name
+  language.code = p.code
+  language.version = block
+  language.happenedIn = await createBlockOrGetFromDatabase(db, block)
+
+  await db.save<Language>(language)
+  return language
+}
+
+async function createVideoMediaEncoding(
+  { db, block, id }: IDBBlockId,
+  p: IVideoMediaEncoding
+): Promise<VideoMediaEncoding> {
+  const record = await db.get(VideoMediaEncoding, { where: { id } })
+  if (record) return record
+
+  const encoding = new VideoMediaEncoding()
+  encoding.id = id
+  encoding.name = p.name
+  encoding.version = block
+  encoding.happenedIn = await createBlockOrGetFromDatabase(db, block)
+  await db.save<VideoMediaEncoding>(encoding)
+  return encoding
+}
+
+async function createLicense(
+  { db, block, id }: IDBBlockId,
+  classEntityMap: ClassEntityMap,
+  p: ILicense,
+  nextEntityIdBeforeTransaction: number
+): Promise<License> {
+  const record = await db.get(License, { where: { id } })
+  if (record) return record
+
+  const { knownLicense, userDefinedLicense } = p
+
+  const license = new License()
+  license.id = id
+  if (knownLicense !== undefined) {
+    license.knownLicense = await getOrCreate.knownLicense(
+      { db, block, id },
+      classEntityMap,
+      knownLicense,
+      nextEntityIdBeforeTransaction
+    )
+  }
+  if (userDefinedLicense !== undefined) {
+    license.userdefinedLicense = await getOrCreate.userDefinedLicense(
+      { db, block, id },
+      classEntityMap,
+      userDefinedLicense,
+      nextEntityIdBeforeTransaction
+    )
+  }
+  license.happenedIn = await createBlockOrGetFromDatabase(db, block)
+  await db.save<License>(license)
+  return license
+}
+
+async function createMediaLocation(
+  { db, block, id }: IDBBlockId,
+  classEntityMap: ClassEntityMap,
+  p: IMediaLocation,
+  nextEntityIdBeforeTransaction: number
+): Promise<MediaLocation> {
+  const { httpMediaLocation, joystreamMediaLocation } = p
+
+  const location = new MediaLocation()
+  location.id = id
+  if (httpMediaLocation !== undefined) {
+    location.httpMediaLocation = await getOrCreate.httpMediaLocation(
+      { db, block, id },
+      classEntityMap,
+      httpMediaLocation,
+      nextEntityIdBeforeTransaction
+    )
+  }
+  if (joystreamMediaLocation !== undefined) {
+    location.joystreamMediaLocation = await getOrCreate.joystreamMediaLocation(
+      { db, block, id },
+      classEntityMap,
+      joystreamMediaLocation,
+      nextEntityIdBeforeTransaction
+    )
+  }
+  location.happenedIn = await createBlockOrGetFromDatabase(db, block)
+  await db.save<License>(location)
+  return location
+}
+
+async function getClassName(
+  db: DB,
+  entity: IEntity,
+  createEntityOperations: ICreateEntityOperation[]
+): Promise<string | undefined> {
+  const { entityId, indexOf } = entity
+  if (entityId === undefined && indexOf === undefined) {
+    throw Error(`Can not determine class of the entity`)
+  }
+
+  let classId: number | undefined
+  // Is newly created entity in the same transaction
+  if (indexOf !== undefined) {
+    classId = createEntityOperations[indexOf].classId
+  } else {
+    const ce = await db.get(ClassEntity, { where: { id: entityId } })
+    if (ce === undefined) console.log(`Class not found for the entity: ${entityId}`)
+    classId = ce ? ce.classId : undefined
+  }
+
+  const c = contentDirectoryClassNamesWithId.find((c) => c.classId === classId)
+  // TODO: stop execution, class should be created before entity creation
+  if (c === undefined) console.log(`Not recognized class id: ${classId}`)
+  return c ? c.name : undefined
+}
+
+export {
+  createCategory,
+  createChannel,
+  createVideoMedia,
+  createVideo,
+  createUserDefinedLicense,
+  createKnownLicense,
+  createHttpMediaLocation,
+  createJoystreamMediaLocation,
+  createLanguage,
+  createVideoMediaEncoding,
+  createLicense,
+  createMediaLocation,
+  createBlockOrGetFromDatabase,
+  getClassName,
+}

+ 89 - 34
query-node/mappings/content-directory/entity.ts → query-node/mappings/content-directory/entity/index.ts

@@ -1,17 +1,23 @@
 import Debug from 'debug'
 import Debug from 'debug'
-import { DB, SubstrateEvent } from '../../generated/indexer'
-import { ClassEntity } from '../../generated/graphql-server/src/modules/class-entity/class-entity.model'
+import { DB, SubstrateEvent } from '../../../generated/indexer'
+import { ClassEntity } from '../../../generated/graphql-server/src/modules/class-entity/class-entity.model'
 
 
-import { decode } from './decode'
+import { decode } from '../decode'
+import {
+  updateCategoryEntityPropertyValues,
+  updateChannelEntityPropertyValues,
+  updateVideoMediaEntityPropertyValues,
+  updateVideoEntityPropertyValues,
+  updateUserDefinedLicenseEntityPropertyValues,
+  updateHttpMediaLocationEntityPropertyValues,
+  updateJoystreamMediaLocationEntityPropertyValues,
+  updateKnownLicenseEntityPropertyValues,
+  updateLanguageEntityPropertyValues,
+  updateVideoMediaEncodingEntityPropertyValues,
+  updateLicenseEntityPropertyValues,
+  updateMediaLocationEntityPropertyValues,
+} from './update'
 import {
 import {
-  createCategory,
-  createChannel,
-  createVideoMedia,
-  createVideo,
-  createUserDefinedLicense,
-  createKnownLicense,
-  createHttpMediaLocation,
-  createJoystreamMediaLocation,
   removeCategory,
   removeCategory,
   removeChannel,
   removeChannel,
   removeVideoMedia,
   removeVideoMedia,
@@ -22,20 +28,22 @@ import {
   removeJoystreamMediaLocation,
   removeJoystreamMediaLocation,
   removeLanguage,
   removeLanguage,
   removeVideoMediaEncoding,
   removeVideoMediaEncoding,
+  removeLicense,
+  removeMediaLocation,
+} from './remove'
+import {
+  createCategory,
+  createChannel,
+  createVideoMedia,
+  createVideo,
+  createUserDefinedLicense,
+  createKnownLicense,
+  createHttpMediaLocation,
+  createJoystreamMediaLocation,
   createLanguage,
   createLanguage,
   createVideoMediaEncoding,
   createVideoMediaEncoding,
-  updateCategoryEntityPropertyValues,
-  updateChannelEntityPropertyValues,
-  updateVideoMediaEntityPropertyValues,
-  updateVideoEntityPropertyValues,
-  updateUserDefinedLicenseEntityPropertyValues,
-  updateHttpMediaLocationEntityPropertyValues,
-  updateJoystreamMediaLocationEntityPropertyValues,
-  updateKnownLicenseEntityPropertyValues,
-  updateLanguageEntityPropertyValues,
-  updateVideoMediaEncodingEntityPropertyValues,
   createBlockOrGetFromDatabase,
   createBlockOrGetFromDatabase,
-} from './entity-helper'
+} from './create'
 import {
 import {
   CategoryPropertyNamesWithId,
   CategoryPropertyNamesWithId,
   channelPropertyNamesWithId,
   channelPropertyNamesWithId,
@@ -48,7 +56,7 @@ import {
   videoPropertyNamesWithId,
   videoPropertyNamesWithId,
   contentDirectoryClassNamesWithId,
   contentDirectoryClassNamesWithId,
   ContentDirectoryKnownClasses,
   ContentDirectoryKnownClasses,
-} from './content-dir-consts'
+} from '../content-dir-consts'
 
 
 import {
 import {
   IChannel,
   IChannel,
@@ -63,7 +71,11 @@ import {
   IVideoMediaEncoding,
   IVideoMediaEncoding,
   IDBBlockId,
   IDBBlockId,
   IWhereCond,
   IWhereCond,
-} from '../types'
+  IEntity,
+  ILicense,
+  IMediaLocation,
+} from '../../types'
+import { getOrCreate } from '../get-or-create'
 
 
 const debug = Debug('mappings:content-directory')
 const debug = Debug('mappings:content-directory')
 
 
@@ -91,7 +103,12 @@ async function contentDirectory_EntitySchemaSupportAdded(db: DB, event: Substrat
 
 
   switch (cls.name) {
   switch (cls.name) {
     case ContentDirectoryKnownClasses.CHANNEL:
     case ContentDirectoryKnownClasses.CHANNEL:
-      await createChannel(arg, decode.setProperties<IChannel>(event, channelPropertyNamesWithId))
+      await createChannel(
+        arg,
+        new Map<string, IEntity[]>(),
+        decode.setProperties<IChannel>(event, channelPropertyNamesWithId),
+        0 // ignored
+      )
       break
       break
 
 
     case ContentDirectoryKnownClasses.CATEGORY:
     case ContentDirectoryKnownClasses.CATEGORY:
@@ -124,11 +141,21 @@ async function contentDirectory_EntitySchemaSupportAdded(db: DB, event: Substrat
       break
       break
 
 
     case ContentDirectoryKnownClasses.VIDEOMEDIA:
     case ContentDirectoryKnownClasses.VIDEOMEDIA:
-      await createVideoMedia(arg, decode.setProperties<IVideoMedia>(event, videoPropertyNamesWithId))
+      await createVideoMedia(
+        arg,
+        new Map<string, IEntity[]>(),
+        decode.setProperties<IVideoMedia>(event, videoPropertyNamesWithId),
+        0 // ignored
+      )
       break
       break
 
 
     case ContentDirectoryKnownClasses.VIDEO:
     case ContentDirectoryKnownClasses.VIDEO:
-      await createVideo(arg, decode.setProperties<IVideo>(event, videoPropertyNamesWithId))
+      await createVideo(
+        arg,
+        new Map<string, IEntity[]>(),
+        decode.setProperties<IVideo>(event, videoPropertyNamesWithId),
+        0 // ignored
+      )
       break
       break
 
 
     case ContentDirectoryKnownClasses.LANGUAGE:
     case ContentDirectoryKnownClasses.LANGUAGE:
@@ -162,7 +189,7 @@ async function contentDirectory_EntityRemoved(db: DB, event: SubstrateEvent): Pr
 
 
   const cls = contentDirectoryClassNamesWithId.find((c) => c.classId === classEntity.classId)
   const cls = contentDirectoryClassNamesWithId.find((c) => c.classId === classEntity.classId)
   if (cls === undefined) {
   if (cls === undefined) {
-    console.log('Undefined class')
+    console.log('Unknown class')
     return
     return
   }
   }
 
 
@@ -206,6 +233,14 @@ async function contentDirectory_EntityRemoved(db: DB, event: SubstrateEvent): Pr
       await removeVideoMediaEncoding(db, where)
       await removeVideoMediaEncoding(db, where)
       break
       break
 
 
+    case ContentDirectoryKnownClasses.LICENSE:
+      await removeLicense(db, where)
+      break
+
+    case ContentDirectoryKnownClasses.MEDIALOCATION:
+      await removeMediaLocation(db, where)
+      break
+
     default:
     default:
       throw new Error(`Unknown class name: ${cls.name}`)
       throw new Error(`Unknown class name: ${cls.name}`)
   }
   }
@@ -224,17 +259,18 @@ async function contentDirectory_EntityCreated(db: DB, event: SubstrateEvent): Pr
   classEntity.version = event.blockNumber
   classEntity.version = event.blockNumber
   classEntity.happenedIn = await createBlockOrGetFromDatabase(db, event.blockNumber)
   classEntity.happenedIn = await createBlockOrGetFromDatabase(db, event.blockNumber)
   await db.save<ClassEntity>(classEntity)
   await db.save<ClassEntity>(classEntity)
+
+  await getOrCreate.nextEntityId(db, c.entityId + 1)
 }
 }
 
 
 // eslint-disable-next-line @typescript-eslint/naming-convention
 // eslint-disable-next-line @typescript-eslint/naming-convention
 async function contentDirectory_EntityPropertyValuesUpdated(db: DB, event: SubstrateEvent): Promise<void> {
 async function contentDirectory_EntityPropertyValuesUpdated(db: DB, event: SubstrateEvent): Promise<void> {
-  debug(`EntityPropertyValuesUpdated event: ${JSON.stringify(event)}`)
-
   const { extrinsic } = event
   const { extrinsic } = event
-
   if (extrinsic && extrinsic.method === 'transaction') return
   if (extrinsic && extrinsic.method === 'transaction') return
   if (extrinsic === undefined) throw Error(`Extrinsic data not found for event: ${event.id}`)
   if (extrinsic === undefined) throw Error(`Extrinsic data not found for event: ${event.id}`)
 
 
+  debug(`EntityPropertyValuesUpdated event: ${JSON.stringify(event)}`)
+
   const { 2: newPropertyValues } = extrinsic.args
   const { 2: newPropertyValues } = extrinsic.args
   const entityId = decode.stringIfyEntityId(event)
   const entityId = decode.stringIfyEntityId(event)
 
 
@@ -253,7 +289,7 @@ async function contentDirectory_EntityPropertyValuesUpdated(db: DB, event: Subst
 
 
   switch (cls.name) {
   switch (cls.name) {
     case ContentDirectoryKnownClasses.CHANNEL:
     case ContentDirectoryKnownClasses.CHANNEL:
-      updateChannelEntityPropertyValues(db, where, decode.setProperties<IChannel>(event, channelPropertyNamesWithId))
+      updateChannelEntityPropertyValues(db, where, decode.setProperties<IChannel>(event, channelPropertyNamesWithId), 0)
       break
       break
 
 
     case ContentDirectoryKnownClasses.CATEGORY:
     case ContentDirectoryKnownClasses.CATEGORY:
@@ -300,12 +336,13 @@ async function contentDirectory_EntityPropertyValuesUpdated(db: DB, event: Subst
       await updateVideoMediaEntityPropertyValues(
       await updateVideoMediaEntityPropertyValues(
         db,
         db,
         where,
         where,
-        decode.setProperties<IVideoMedia>(event, videoPropertyNamesWithId)
+        decode.setProperties<IVideoMedia>(event, videoPropertyNamesWithId),
+        0
       )
       )
       break
       break
 
 
     case ContentDirectoryKnownClasses.VIDEO:
     case ContentDirectoryKnownClasses.VIDEO:
-      await updateVideoEntityPropertyValues(db, where, decode.setProperties<IVideo>(event, videoPropertyNamesWithId))
+      await updateVideoEntityPropertyValues(db, where, decode.setProperties<IVideo>(event, videoPropertyNamesWithId), 0)
       break
       break
 
 
     case ContentDirectoryKnownClasses.LANGUAGE:
     case ContentDirectoryKnownClasses.LANGUAGE:
@@ -324,6 +361,24 @@ async function contentDirectory_EntityPropertyValuesUpdated(db: DB, event: Subst
       )
       )
       break
       break
 
 
+    case ContentDirectoryKnownClasses.LICENSE:
+      await updateLicenseEntityPropertyValues(
+        db,
+        where,
+        decode.setProperties<ILicense>(event, videoMediaEncodingPropertyNamesWithId),
+        0
+      )
+      break
+
+    case ContentDirectoryKnownClasses.MEDIALOCATION:
+      await updateMediaLocationEntityPropertyValues(
+        db,
+        where,
+        decode.setProperties<IMediaLocation>(event, videoMediaEncodingPropertyNamesWithId),
+        0
+      )
+      break
+
     default:
     default:
       throw new Error(`Unknown class name: ${cls.name}`)
       throw new Error(`Unknown class name: ${cls.name}`)
   }
   }

+ 108 - 0
query-node/mappings/content-directory/entity/remove.ts

@@ -0,0 +1,108 @@
+import { DB } from '../../../generated/indexer'
+import { Channel } from '../../../generated/graphql-server/src/modules/channel/channel.model'
+import { Category } from '../../../generated/graphql-server/src/modules/category/category.model'
+import { KnownLicense } from '../../../generated/graphql-server/src/modules/known-license/known-license.model'
+import { UserDefinedLicense } from '../../../generated/graphql-server/src/modules/user-defined-license/user-defined-license.model'
+import { JoystreamMediaLocation } from '../../../generated/graphql-server/src/modules/joystream-media-location/joystream-media-location.model'
+import { HttpMediaLocation } from '../../../generated/graphql-server/src/modules/http-media-location/http-media-location.model'
+import { VideoMedia } from '../../../generated/graphql-server/src/modules/video-media/video-media.model'
+import { Video } from '../../../generated/graphql-server/src/modules/video/video.model'
+import { Language } from '../../../generated/graphql-server/src/modules/language/language.model'
+import { VideoMediaEncoding } from '../../../generated/graphql-server/src/modules/video-media-encoding/video-media-encoding.model'
+import { License } from '../../../generated/graphql-server/src/modules/license/license.model'
+import { MediaLocation } from '../../../generated/graphql-server/src/modules/media-location/media-location.model'
+
+import { IWhereCond } from '../../types'
+
+async function removeChannel(db: DB, where: IWhereCond): Promise<void> {
+  const record = await db.get(Channel, where)
+  if (record === undefined) throw Error(`Channel not found`)
+  if (record.videos) record.videos.map(async (v) => await removeVideo(db, { where: { id: v.id } }))
+  await db.remove<Channel>(record)
+}
+async function removeCategory(db: DB, where: IWhereCond): Promise<void> {
+  const record = await db.get(Category, where)
+  if (record === undefined) throw Error(`Category not found`)
+  if (record.videos) record.videos.map(async (v) => await removeVideo(db, { where: { id: v.id } }))
+  await db.remove<Category>(record)
+}
+async function removeVideoMedia(db: DB, where: IWhereCond): Promise<void> {
+  const record = await db.get(VideoMedia, where)
+  if (record === undefined) throw Error(`VideoMedia not found`)
+  if (record.video) await db.remove<Video>(record.video)
+  await db.remove<VideoMedia>(record)
+}
+async function removeVideo(db: DB, where: IWhereCond): Promise<void> {
+  const record = await db.get(Video, where)
+  if (record === undefined) throw Error(`Video not found`)
+  await db.remove<Video>(record)
+}
+
+async function removeLicense(db: DB, where: IWhereCond): Promise<void> {
+  const record = await db.get(License, where)
+  if (record === undefined) throw Error(`License not found`)
+  // Remove all the videos under this license
+  if (record.videolicense) record.videolicense.map(async (v) => await removeVideo(db, { where: { id: v.id } }))
+  await db.remove<License>(record)
+}
+async function removeUserDefinedLicense(db: DB, where: IWhereCond): Promise<void> {
+  const record = await db.get(UserDefinedLicense, where)
+  if (record === undefined) throw Error(`UserDefinedLicense not found`)
+  if (record.licenseuserdefinedLicense)
+    record.licenseuserdefinedLicense.map(async (l) => await removeLicense(db, { where: { id: l.id } }))
+  await db.remove<UserDefinedLicense>(record)
+}
+async function removeKnownLicense(db: DB, where: IWhereCond): Promise<void> {
+  const record = await db.get(KnownLicense, where)
+  if (record === undefined) throw Error(`KnownLicense not found`)
+  if (record.licenseknownLicense)
+    record.licenseknownLicense.map(async (k) => await removeLicense(db, { where: { id: k.id } }))
+  await db.remove<KnownLicense>(record)
+}
+async function removeMediaLocation(db: DB, where: IWhereCond): Promise<void> {
+  const record = await db.get(MediaLocation, where)
+  if (record === undefined) throw Error(`MediaLocation not found`)
+  if (record.videoMedia) await removeVideo(db, { where: { id: record.videoMedia.id } })
+  await db.remove<MediaLocation>(record)
+}
+async function removeHttpMediaLocation(db: DB, where: IWhereCond): Promise<void> {
+  const record = await db.get(HttpMediaLocation, where)
+  if (record === undefined) throw Error(`HttpMediaLocation not found`)
+  if (record.medialocationhttpMediaLocation)
+    record.medialocationhttpMediaLocation.map(async (v) => await removeMediaLocation(db, { where: { id: v.id } }))
+  await db.remove<HttpMediaLocation>(record)
+}
+async function removeJoystreamMediaLocation(db: DB, where: IWhereCond): Promise<void> {
+  const record = await db.get(JoystreamMediaLocation, where)
+  if (record === undefined) throw Error(`JoystreamMediaLocation not found`)
+  if (record.medialocationjoystreamMediaLocation)
+    record.medialocationjoystreamMediaLocation.map(async (v) => await removeVideo(db, { where: { id: v.id } }))
+  await db.remove<JoystreamMediaLocation>(record)
+}
+async function removeLanguage(db: DB, where: IWhereCond): Promise<void> {
+  const record = await db.get(Language, where)
+  if (record === undefined) throw Error(`Language not found`)
+  if (record.channellanguage) record.channellanguage.map(async (c) => await removeChannel(db, { where: { id: c.id } }))
+  if (record.videolanguage) record.videolanguage.map(async (v) => await removeVideo(db, { where: { id: v.id } }))
+  await db.remove<Language>(record)
+}
+async function removeVideoMediaEncoding(db: DB, where: IWhereCond): Promise<void> {
+  const record = await db.get(VideoMediaEncoding, where)
+  if (record === undefined) throw Error(`Language not found`)
+  await db.remove<VideoMediaEncoding>(record)
+}
+
+export {
+  removeCategory,
+  removeChannel,
+  removeVideoMedia,
+  removeVideo,
+  removeUserDefinedLicense,
+  removeKnownLicense,
+  removeHttpMediaLocation,
+  removeJoystreamMediaLocation,
+  removeLanguage,
+  removeVideoMediaEncoding,
+  removeMediaLocation,
+  removeLicense,
+}

+ 260 - 0
query-node/mappings/content-directory/entity/update.ts

@@ -0,0 +1,260 @@
+import { DB } from '../../../generated/indexer'
+import { Channel } from '../../../generated/graphql-server/src/modules/channel/channel.model'
+import { Category } from '../../../generated/graphql-server/src/modules/category/category.model'
+import { KnownLicense } from '../../../generated/graphql-server/src/modules/known-license/known-license.model'
+import { UserDefinedLicense } from '../../../generated/graphql-server/src/modules/user-defined-license/user-defined-license.model'
+import { JoystreamMediaLocation } from '../../../generated/graphql-server/src/modules/joystream-media-location/joystream-media-location.model'
+import { HttpMediaLocation } from '../../../generated/graphql-server/src/modules/http-media-location/http-media-location.model'
+import { VideoMedia } from '../../../generated/graphql-server/src/modules/video-media/video-media.model'
+import { Video } from '../../../generated/graphql-server/src/modules/video/video.model'
+import { Language } from '../../../generated/graphql-server/src/modules/language/language.model'
+import { VideoMediaEncoding } from '../../../generated/graphql-server/src/modules/video-media-encoding/video-media-encoding.model'
+import { License } from '../../../generated/graphql-server/src/modules/license/license.model'
+import { MediaLocation } from '../../../generated/graphql-server/src/modules/media-location/media-location.model'
+
+import {
+  ICategory,
+  IChannel,
+  IHttpMediaLocation,
+  IJoystreamMediaLocation,
+  IKnownLicense,
+  ILanguage,
+  ILicense,
+  IMediaLocation,
+  IReference,
+  IUserDefinedLicense,
+  IVideo,
+  IVideoMedia,
+  IVideoMediaEncoding,
+  IWhereCond,
+} from '../../types'
+
+function getEntityIdFromReferencedField(ref: IReference, entityIdBeforeTransaction: number): string {
+  const { entityId, existing } = ref
+  const id = existing ? entityId : entityIdBeforeTransaction + entityId
+  return id.toString()
+}
+
+async function updateMediaLocationEntityPropertyValues(
+  db: DB,
+  where: IWhereCond,
+  props: IMediaLocation,
+  entityIdBeforeTransaction: number
+): Promise<void> {
+  const { httpMediaLocation, joystreamMediaLocation } = props
+  const record = await db.get(MediaLocation, where)
+  if (record === undefined) throw Error(`MediaLocation entity not found: ${where.where.id}`)
+
+  if (httpMediaLocation) {
+    const id = getEntityIdFromReferencedField(httpMediaLocation, entityIdBeforeTransaction)
+    record.httpMediaLocation = await db.get(HttpMediaLocation, { where: { id } })
+  }
+  if (joystreamMediaLocation) {
+    const id = getEntityIdFromReferencedField(joystreamMediaLocation, entityIdBeforeTransaction)
+    record.joystreamMediaLocation = await db.get(JoystreamMediaLocation, { where: { id } })
+  }
+  await db.save<MediaLocation>(record)
+}
+
+async function updateLicenseEntityPropertyValues(
+  db: DB,
+  where: IWhereCond,
+  props: ILicense,
+  entityIdBeforeTransaction: number
+): Promise<void> {
+  const record = await db.get(License, where)
+  if (record === undefined) throw Error(`License entity not found: ${where.where.id}`)
+
+  const { knownLicense, userDefinedLicense } = props
+  if (knownLicense) {
+    const id = getEntityIdFromReferencedField(knownLicense, entityIdBeforeTransaction)
+    record.knownLicense = await db.get(KnownLicense, { where: { id } })
+  }
+  if (userDefinedLicense) {
+    const id = getEntityIdFromReferencedField(userDefinedLicense, entityIdBeforeTransaction)
+    record.userdefinedLicense = await db.get(UserDefinedLicense, { where: { id } })
+  }
+  await db.save<License>(record)
+}
+
+async function updateCategoryEntityPropertyValues(db: DB, where: IWhereCond, props: ICategory): Promise<void> {
+  const record = await db.get(Category, where)
+  if (record === undefined) throw Error(`Entity not found: ${where.where.id}`)
+  Object.assign(record, props)
+  await db.save<Category>(record)
+}
+async function updateChannelEntityPropertyValues(
+  db: DB,
+  where: IWhereCond,
+  props: IChannel,
+  entityIdBeforeTransaction: number
+): Promise<void> {
+  const record = await db.get(Channel, where)
+  if (record === undefined) throw Error(`Entity not found: ${where.where.id}`)
+
+  let lang: Language | undefined
+  if (props.language !== undefined) {
+    const id = getEntityIdFromReferencedField(props.language, entityIdBeforeTransaction)
+    lang = await db.get(Language, { where: { id } })
+    if (lang === undefined) throw Error(`Language entity not found: ${id}`)
+    props.language = undefined
+  }
+  Object.assign(record, props)
+
+  record.language = lang || record.language
+  await db.save<Channel>(record)
+}
+async function updateVideoMediaEntityPropertyValues(
+  db: DB,
+  where: IWhereCond,
+  props: IVideoMedia,
+  entityIdBeforeTransaction: number
+): Promise<void> {
+  const record = await db.get(VideoMedia, where)
+  if (record === undefined) throw Error(`Entity not found: ${where.where.id}`)
+
+  let enco: VideoMediaEncoding | undefined
+  let mediaLoc: MediaLocation | undefined
+  const { encoding, location } = props
+  if (encoding) {
+    const id = getEntityIdFromReferencedField(encoding, entityIdBeforeTransaction)
+    enco = await db.get(VideoMediaEncoding, { where: { id } })
+    if (enco === undefined) throw Error(`VideoMediaEncoding entity not found: ${id}`)
+    props.encoding = undefined
+  }
+  if (location) {
+    const id = getEntityIdFromReferencedField(location, entityIdBeforeTransaction)
+    mediaLoc = await db.get(MediaLocation, { where: { id } })
+    if (!mediaLoc) throw Error(`MediaLocation entity not found: ${id}`)
+    props.location = undefined
+  }
+  Object.assign(record, props)
+
+  record.encoding = enco || record.encoding
+  record.location = mediaLoc || record.location
+  await db.save<VideoMedia>(record)
+}
+async function updateVideoEntityPropertyValues(
+  db: DB,
+  where: IWhereCond,
+  props: IVideo,
+  entityIdBeforeTransaction: number
+): Promise<void> {
+  const record = await db.get<Video>(Video, where)
+  if (record === undefined) throw Error(`Entity not found: ${where.where.id}`)
+
+  let chann: Channel | undefined
+  let cat: Category | undefined
+  let lang: Language | undefined
+  let vMedia: VideoMedia | undefined
+  let lic: License | undefined
+  const { channel, category, language, media, license } = props
+  if (channel) {
+    const id = getEntityIdFromReferencedField(channel, entityIdBeforeTransaction)
+    chann = await db.get(Channel, { where: { id } })
+    if (!chann) throw Error(`Channel entity not found: ${id}`)
+    props.channel = undefined
+  }
+  if (category) {
+    const id = getEntityIdFromReferencedField(category, entityIdBeforeTransaction)
+    cat = await db.get(Category, { where: { id } })
+    if (!cat) throw Error(`Category entity not found: ${id}`)
+    props.category = undefined
+  }
+  if (media) {
+    const id = getEntityIdFromReferencedField(media, entityIdBeforeTransaction)
+    vMedia = await db.get(VideoMedia, { where: { id } })
+    if (!vMedia) throw Error(`VideoMedia entity not found: ${id}`)
+    props.media = undefined
+  }
+  if (license) {
+    const id = getEntityIdFromReferencedField(license, entityIdBeforeTransaction)
+    lic = await db.get(License, { where: { id } })
+    if (!lic) throw Error(`License entity not found: ${id}`)
+    props.license = undefined
+  }
+  if (language) {
+    const id = getEntityIdFromReferencedField(language, entityIdBeforeTransaction)
+    lang = await db.get(Language, { where: { id } })
+    if (!lang) throw Error(`Language entity not found: ${id}`)
+    props.language = undefined
+  }
+
+  Object.assign(record, props)
+
+  record.channel = chann || record.channel
+  record.category = cat || record.category
+  record.media = vMedia || record.media
+  record.license = lic || record.license
+  record.language = lang
+
+  await db.save<Video>(record)
+}
+async function updateUserDefinedLicenseEntityPropertyValues(
+  db: DB,
+  where: IWhereCond,
+  props: IUserDefinedLicense
+): Promise<void> {
+  const record = await db.get(UserDefinedLicense, where)
+  if (record === undefined) throw Error(`Entity not found: ${where.where.id}`)
+  Object.assign(record, props)
+  await db.save<UserDefinedLicense>(record)
+}
+async function updateKnownLicenseEntityPropertyValues(db: DB, where: IWhereCond, props: IKnownLicense): Promise<void> {
+  const record = await db.get(KnownLicense, where)
+  if (record === undefined) throw Error(`Entity not found: ${where.where.id}`)
+  Object.assign(record, props)
+  await db.save<KnownLicense>(record)
+}
+async function updateHttpMediaLocationEntityPropertyValues(
+  db: DB,
+  where: IWhereCond,
+  props: IHttpMediaLocation
+): Promise<void> {
+  const record = await db.get(HttpMediaLocation, where)
+  if (record === undefined) throw Error(`Entity not found: ${where.where.id}`)
+  Object.assign(record, props)
+  await db.save<HttpMediaLocation>(record)
+}
+
+async function updateJoystreamMediaLocationEntityPropertyValues(
+  db: DB,
+  where: IWhereCond,
+  props: IJoystreamMediaLocation
+): Promise<void> {
+  const record = await db.get(JoystreamMediaLocation, where)
+  if (record === undefined) throw Error(`Entity not found: ${where.where.id}`)
+  Object.assign(record, props)
+  await db.save<JoystreamMediaLocation>(record)
+}
+async function updateLanguageEntityPropertyValues(db: DB, where: IWhereCond, props: ILanguage): Promise<void> {
+  const record = await db.get(Language, where)
+  if (record === undefined) throw Error(`Entity not found: ${where.where.id}`)
+  Object.assign(record, props)
+  await db.save<Language>(record)
+}
+async function updateVideoMediaEncodingEntityPropertyValues(
+  db: DB,
+  where: IWhereCond,
+  props: IVideoMediaEncoding
+): Promise<void> {
+  const record = await db.get(VideoMediaEncoding, where)
+  if (record === undefined) throw Error(`Entity not found: ${where.where.id}`)
+  Object.assign(record, props)
+  await db.save<VideoMediaEncoding>(record)
+}
+
+export {
+  updateCategoryEntityPropertyValues,
+  updateChannelEntityPropertyValues,
+  updateVideoMediaEntityPropertyValues,
+  updateVideoEntityPropertyValues,
+  updateUserDefinedLicenseEntityPropertyValues,
+  updateHttpMediaLocationEntityPropertyValues,
+  updateJoystreamMediaLocationEntityPropertyValues,
+  updateKnownLicenseEntityPropertyValues,
+  updateLanguageEntityPropertyValues,
+  updateVideoMediaEncodingEntityPropertyValues,
+  updateLicenseEntityPropertyValues,
+  updateMediaLocationEntityPropertyValues,
+}

+ 411 - 0
query-node/mappings/content-directory/get-or-create.ts

@@ -0,0 +1,411 @@
+import { Channel } from '../../generated/graphql-server/src/modules/channel/channel.model'
+import { Category } from '../../generated/graphql-server/src/modules/category/category.model'
+import { KnownLicense } from '../../generated/graphql-server/src/modules/known-license/known-license.model'
+import { UserDefinedLicense } from '../../generated/graphql-server/src/modules/user-defined-license/user-defined-license.model'
+import { JoystreamMediaLocation } from '../../generated/graphql-server/src/modules/joystream-media-location/joystream-media-location.model'
+import { HttpMediaLocation } from '../../generated/graphql-server/src/modules/http-media-location/http-media-location.model'
+import { VideoMedia } from '../../generated/graphql-server/src/modules/video-media/video-media.model'
+import { Language } from '../../generated/graphql-server/src/modules/language/language.model'
+import { VideoMediaEncoding } from '../../generated/graphql-server/src/modules/video-media-encoding/video-media-encoding.model'
+import { License } from '../../generated/graphql-server/src/modules/license/license.model'
+import { MediaLocation } from '../../generated/graphql-server/src/modules/media-location/media-location.model'
+import { NextEntityId } from '../../generated/graphql-server/src/modules/next-entity-id/next-entity-id.model'
+
+import { decode } from './decode'
+import {
+  CategoryPropertyNamesWithId,
+  channelPropertyNamesWithId,
+  httpMediaLocationPropertyNamesWithId,
+  joystreamMediaLocationPropertyNamesWithId,
+  knownLicensePropertyNamesWIthId,
+  languagePropertyNamesWIthId,
+  licensePropertyNamesWithId,
+  mediaLocationPropertyNamesWithId,
+  userDefinedLicensePropertyNamesWithId,
+  videoMediaEncodingPropertyNamesWithId,
+  videoPropertyNamesWithId,
+} from './content-dir-consts'
+import {
+  ClassEntityMap,
+  ICategory,
+  IChannel,
+  IDBBlockId,
+  IEntity,
+  IHttpMediaLocation,
+  IJoystreamMediaLocation,
+  IKnownLicense,
+  ILanguage,
+  ILicense,
+  IMediaLocation,
+  IReference,
+  IUserDefinedLicense,
+  IVideoMedia,
+  IVideoMediaEncoding,
+} from '../types'
+
+import {
+  createCategory,
+  createChannel,
+  createVideoMedia,
+  createUserDefinedLicense,
+  createKnownLicense,
+  createHttpMediaLocation,
+  createJoystreamMediaLocation,
+  createLanguage,
+  createVideoMediaEncoding,
+  createLicense,
+  createMediaLocation,
+} from './entity/create'
+
+import { DB } from '../../generated/indexer'
+
+// Keep track of the next entity id
+async function nextEntityId(db: DB, nextEntityId: number): Promise<void> {
+  let e = await db.get(NextEntityId, { where: { id: '1' } })
+  if (!e) e = new NextEntityId({ id: '1' })
+  e.nextId = nextEntityId
+  await db.save<NextEntityId>(e)
+}
+
+function generateEntityIdFromIndex(index: number): string {
+  return `${index}`
+}
+
+function findEntity(entityId: number, className: string, classEntityMap: ClassEntityMap): IEntity {
+  const newlyCreatedEntities = classEntityMap.get(className)
+  if (newlyCreatedEntities === undefined) throw Error(`Couldn't find '${className}' entities in the classEntityMap`)
+  const entity = newlyCreatedEntities.find((e) => e.indexOf === entityId)
+  if (!entity) throw Error(`Unknown ${className} entity id: ${entityId}`)
+  removeInsertedEntity(className, entityId, classEntityMap)
+  return entity
+}
+
+async function language(
+  { db, block }: IDBBlockId,
+  classEntityMap: ClassEntityMap,
+  language: IReference,
+  nextEntityIdBeforeTransaction: number
+): Promise<Language> {
+  let lang
+  const { entityId, existing } = language
+  if (existing) {
+    lang = await db.get(Language, { where: { id: entityId.toString() } })
+    if (!lang) throw Error(`Language entity not found`)
+    return lang
+  }
+
+  const id = generateEntityIdFromIndex(nextEntityIdBeforeTransaction + entityId)
+  // could be created in the transaction
+  lang = await db.get(Language, { where: { id } })
+  if (lang) return lang
+
+  // get the entity from list of newly created entities and insert into db
+  const { properties } = findEntity(entityId, 'Language', classEntityMap)
+  return await createLanguage(
+    { db, block, id },
+    decode.setEntityPropertyValues<ILanguage>(properties, languagePropertyNamesWIthId)
+  )
+}
+
+async function videoMediaEncoding(
+  { db, block }: IDBBlockId,
+  classEntityMap: ClassEntityMap,
+  encoding: IReference,
+  nextEntityIdBeforeTransaction: number
+): Promise<VideoMediaEncoding> {
+  let vmEncoding
+  const { entityId, existing } = encoding
+  if (existing) {
+    vmEncoding = await db.get(VideoMediaEncoding, { where: { id: entityId.toString() } })
+    if (!vmEncoding) throw Error(`VideoMediaEncoding entity not found`)
+    return vmEncoding
+  }
+
+  const id = generateEntityIdFromIndex(nextEntityIdBeforeTransaction + entityId)
+
+  // could be created in the transaction
+  vmEncoding = await db.get(VideoMediaEncoding, { where: { id } })
+  if (vmEncoding) return vmEncoding
+
+  const { properties } = findEntity(entityId, 'VideoMediaEncoding', classEntityMap)
+  return await createVideoMediaEncoding(
+    { db, block, id },
+    decode.setEntityPropertyValues<IVideoMediaEncoding>(properties, videoMediaEncodingPropertyNamesWithId)
+  )
+}
+
+async function videoMedia(
+  { db, block }: IDBBlockId,
+  classEntityMap: ClassEntityMap,
+  media: IReference,
+  nextEntityIdBeforeTransaction: number
+): Promise<VideoMedia> {
+  let videoM: VideoMedia | undefined
+  const { entityId, existing } = media
+  if (existing) {
+    videoM = await db.get(VideoMedia, { where: { id: entityId.toString() } })
+    if (!videoM) throw Error(`VideoMedia entity not found`)
+    return videoM
+  }
+  const id = generateEntityIdFromIndex(nextEntityIdBeforeTransaction + entityId)
+
+  // could be created in the transaction
+  videoM = await db.get(VideoMedia, { where: { id } })
+  if (videoM) return videoM
+
+  const { properties } = findEntity(entityId, 'VideoMedia', classEntityMap)
+  return await createVideoMedia(
+    { db, block, id },
+    classEntityMap,
+    decode.setEntityPropertyValues<IVideoMedia>(properties, videoPropertyNamesWithId),
+    nextEntityIdBeforeTransaction
+  )
+}
+
+async function knownLicense(
+  { db, block }: IDBBlockId,
+  classEntityMap: ClassEntityMap,
+  knownLicense: IReference,
+  nextEntityIdBeforeTransaction: number
+): Promise<KnownLicense> {
+  let kLicense: KnownLicense | undefined
+  const { entityId, existing } = knownLicense
+  if (existing) {
+    kLicense = await db.get(KnownLicense, { where: { id: entityId.toString() } })
+    if (!kLicense) throw Error(`KnownLicense entity not found`)
+    return kLicense
+  }
+  const id = generateEntityIdFromIndex(nextEntityIdBeforeTransaction + entityId)
+  // could be created in the transaction
+  kLicense = await db.get(KnownLicense, { where: { id } })
+  if (kLicense) return kLicense
+
+  const { properties } = findEntity(entityId, 'KnownLicense', classEntityMap)
+  return await createKnownLicense(
+    { db, block, id },
+    decode.setEntityPropertyValues<IKnownLicense>(properties, knownLicensePropertyNamesWIthId)
+  )
+}
+async function userDefinedLicense(
+  { db, block }: IDBBlockId,
+  classEntityMap: ClassEntityMap,
+  userDefinedLicense: IReference,
+  nextEntityIdBeforeTransaction: number
+): Promise<UserDefinedLicense> {
+  let udLicense: UserDefinedLicense | undefined
+  const { entityId, existing } = userDefinedLicense
+  if (existing) {
+    udLicense = await db.get(UserDefinedLicense, { where: { id: entityId.toString() } })
+    if (!udLicense) throw Error(`UserDefinedLicense entity not found`)
+    return udLicense
+  }
+  const id = generateEntityIdFromIndex(nextEntityIdBeforeTransaction + entityId)
+  // could be created in the transaction
+  udLicense = await db.get(UserDefinedLicense, {
+    where: { id },
+  })
+  if (udLicense) return udLicense
+
+  const { properties } = findEntity(entityId, 'UserDefinedLicense', classEntityMap)
+  return await createUserDefinedLicense(
+    { db, block, id },
+    decode.setEntityPropertyValues<IUserDefinedLicense>(properties, userDefinedLicensePropertyNamesWithId)
+  )
+}
+
+async function channel(
+  { db, block }: IDBBlockId,
+  classEntityMap: ClassEntityMap,
+  channel: IReference,
+  nextEntityIdBeforeTransaction: number
+): Promise<Channel> {
+  let chann: Channel | undefined
+  const { entityId, existing } = channel
+
+  if (existing) {
+    chann = await db.get(Channel, { where: { id: entityId.toString() } })
+    if (!chann) throw Error(`Channel entity not found`)
+    return chann
+  }
+
+  const id = generateEntityIdFromIndex(nextEntityIdBeforeTransaction + entityId)
+  // could be created in the transaction
+  chann = await db.get(Channel, { where: { id } })
+  if (chann) return chann
+
+  const { properties } = findEntity(entityId, 'Channel', classEntityMap)
+  return await createChannel(
+    { db, block, id },
+    classEntityMap,
+    decode.setEntityPropertyValues<IChannel>(properties, channelPropertyNamesWithId),
+    nextEntityIdBeforeTransaction
+  )
+}
+
+async function category(
+  { db, block }: IDBBlockId,
+  classEntityMap: ClassEntityMap,
+  category: IReference,
+  nextEntityIdBeforeTransaction: number
+): Promise<Category> {
+  let cat: Category | undefined
+  const { entityId, existing } = category
+
+  if (existing) {
+    cat = await db.get(Category, { where: { id: entityId.toString() } })
+    if (!cat) throw Error(`Category entity not found`)
+    return cat
+  }
+  const id = generateEntityIdFromIndex(nextEntityIdBeforeTransaction + entityId)
+  // could be created in the transaction
+  cat = await db.get(Category, { where: { id } })
+  if (cat) return cat
+
+  const { properties } = findEntity(entityId, 'Category', classEntityMap)
+  return await createCategory(
+    { db, block, id },
+    decode.setEntityPropertyValues<ICategory>(properties, CategoryPropertyNamesWithId)
+  )
+}
+
+async function httpMediaLocation(
+  { db, block }: IDBBlockId,
+  classEntityMap: ClassEntityMap,
+  httpMediaLoc: IReference,
+  nextEntityIdBeforeTransaction: number
+): Promise<HttpMediaLocation | undefined> {
+  let loc: HttpMediaLocation | undefined
+  const { entityId, existing } = httpMediaLoc
+
+  if (existing) {
+    loc = await db.get(HttpMediaLocation, { where: { id: entityId.toString() } })
+    if (!loc) throw Error(`HttpMediaLocation entity not found`)
+    return loc
+  }
+  const id = generateEntityIdFromIndex(nextEntityIdBeforeTransaction + entityId)
+
+  // could be created in the transaction
+  loc = await db.get(HttpMediaLocation, {
+    where: { id },
+  })
+  if (loc) return loc
+
+  const { properties } = findEntity(entityId, 'HttpMediaLocation', classEntityMap)
+  return await createHttpMediaLocation(
+    { db, block, id },
+    decode.setEntityPropertyValues<IHttpMediaLocation>(properties, httpMediaLocationPropertyNamesWithId)
+  )
+}
+
+async function joystreamMediaLocation(
+  { db, block }: IDBBlockId,
+  classEntityMap: ClassEntityMap,
+  joyMediaLoc: IReference,
+  nextEntityIdBeforeTransaction: number
+): Promise<JoystreamMediaLocation | undefined> {
+  let loc: JoystreamMediaLocation | undefined
+  const { entityId, existing } = joyMediaLoc
+
+  if (existing) {
+    loc = await db.get(JoystreamMediaLocation, { where: { id: entityId.toString() } })
+    if (!loc) throw Error(`JoystreamMediaLocation entity not found`)
+    return loc
+  }
+
+  const id = generateEntityIdFromIndex(nextEntityIdBeforeTransaction + entityId)
+
+  // could be created in the transaction
+  loc = await db.get(JoystreamMediaLocation, {
+    where: { id },
+  })
+  if (loc) return loc
+
+  const { properties } = findEntity(entityId, 'JoystreamMediaLocation', classEntityMap)
+  return await createJoystreamMediaLocation(
+    { db, block, id },
+    decode.setEntityPropertyValues<IJoystreamMediaLocation>(properties, joystreamMediaLocationPropertyNamesWithId)
+  )
+}
+
+async function license(
+  { db, block }: IDBBlockId,
+  classEntityMap: ClassEntityMap,
+  license: IReference,
+  nextEntityIdBeforeTransaction: number
+): Promise<License> {
+  let lic: License | undefined
+  const { entityId, existing } = license
+
+  if (existing) {
+    lic = await db.get(License, { where: { id: entityId.toString() } })
+    if (!lic) throw Error(`License entity not found`)
+    return lic
+  }
+
+  const id = generateEntityIdFromIndex(nextEntityIdBeforeTransaction + entityId)
+  // could be created in the transaction
+  lic = await db.get(License, { where: { id } })
+  if (lic) return lic
+
+  const { properties } = findEntity(entityId, 'License', classEntityMap)
+  return await createLicense(
+    { db, block, id },
+    classEntityMap,
+    decode.setEntityPropertyValues<ILicense>(properties, licensePropertyNamesWithId),
+    nextEntityIdBeforeTransaction
+  )
+}
+
+async function mediaLocation(
+  { db, block }: IDBBlockId,
+  classEntityMap: ClassEntityMap,
+  location: IReference,
+  nextEntityIdBeforeTransaction: number
+): Promise<MediaLocation> {
+  let loc: MediaLocation | undefined
+  const { entityId, existing } = location
+  if (existing) {
+    loc = await db.get(MediaLocation, { where: { id: entityId.toString() } })
+    if (!loc) throw Error(`MediaLocation entity not found`)
+    return loc
+  }
+  const id = generateEntityIdFromIndex(nextEntityIdBeforeTransaction + entityId)
+
+  // could be created in the transaction
+  loc = await db.get(MediaLocation, {
+    where: { id },
+  })
+  if (loc) return loc
+
+  const { properties } = findEntity(entityId, 'MediaLocation', classEntityMap)
+  return await createMediaLocation(
+    { db, block, id },
+    classEntityMap,
+    decode.setEntityPropertyValues<IMediaLocation>(properties, mediaLocationPropertyNamesWithId),
+    nextEntityIdBeforeTransaction
+  )
+}
+
+function removeInsertedEntity(key: string, insertedEntityId: number, classEntityMap: ClassEntityMap) {
+  const newlyCreatedEntities = classEntityMap.get(key)
+  // Remove the inserted entity from the list
+  classEntityMap.set(
+    key,
+    newlyCreatedEntities!.filter((e) => e.entityId !== insertedEntityId)
+  )
+}
+
+export const getOrCreate = {
+  language,
+  videoMediaEncoding,
+  videoMedia,
+  knownLicense,
+  userDefinedLicense,
+  channel,
+  category,
+  joystreamMediaLocation,
+  httpMediaLocation,
+  license,
+  mediaLocation,
+  nextEntityId,
+}

+ 201 - 94
query-node/mappings/content-directory/transaction.ts

@@ -1,8 +1,12 @@
 import Debug from 'debug'
 import Debug from 'debug'
 
 
 import { DB, SubstrateEvent } from '../../generated/indexer'
 import { DB, SubstrateEvent } from '../../generated/indexer'
+import { NextEntityId } from '../../generated/graphql-server/src/modules/next-entity-id/next-entity-id.model'
+import { ClassEntity } from '../../generated/graphql-server/src/modules/class-entity/class-entity.model'
+
 import { decode } from './decode'
 import { decode } from './decode'
 import {
 import {
+  ClassEntityMap,
   ICategory,
   ICategory,
   IChannel,
   IChannel,
   ICreateEntityOperation,
   ICreateEntityOperation,
@@ -12,6 +16,8 @@ import {
   IJoystreamMediaLocation,
   IJoystreamMediaLocation,
   IKnownLicense,
   IKnownLicense,
   ILanguage,
   ILanguage,
+  ILicense,
+  IMediaLocation,
   IUserDefinedLicense,
   IUserDefinedLicense,
   IVideo,
   IVideo,
   IVideoMedia,
   IVideoMedia,
@@ -30,19 +36,10 @@ import {
   videoPropertyNamesWithId,
   videoPropertyNamesWithId,
   languagePropertyNamesWIthId,
   languagePropertyNamesWIthId,
   ContentDirectoryKnownClasses,
   ContentDirectoryKnownClasses,
+  licensePropertyNamesWithId,
+  mediaLocationPropertyNamesWithId,
 } from './content-dir-consts'
 } from './content-dir-consts'
 import {
 import {
-  createCategory,
-  createChannel,
-  createVideoMedia,
-  createVideo,
-  createUserDefinedLicense,
-  createKnownLicense,
-  createHttpMediaLocation,
-  createJoystreamMediaLocation,
-  createLanguage,
-  createVideoMediaEncoding,
-  getClassName,
   updateCategoryEntityPropertyValues,
   updateCategoryEntityPropertyValues,
   updateChannelEntityPropertyValues,
   updateChannelEntityPropertyValues,
   updateVideoMediaEntityPropertyValues,
   updateVideoMediaEntityPropertyValues,
@@ -53,10 +50,36 @@ import {
   updateKnownLicenseEntityPropertyValues,
   updateKnownLicenseEntityPropertyValues,
   updateLanguageEntityPropertyValues,
   updateLanguageEntityPropertyValues,
   updateVideoMediaEncodingEntityPropertyValues,
   updateVideoMediaEncodingEntityPropertyValues,
-  batchCreateClassEntities,
-} from './entity-helper'
+  updateLicenseEntityPropertyValues,
+  updateMediaLocationEntityPropertyValues,
+} from './entity/update'
 
 
-const debug = Debug('mappings:content-directory')
+import {
+  createCategory,
+  createChannel,
+  createVideoMedia,
+  createVideo,
+  createUserDefinedLicense,
+  createKnownLicense,
+  createHttpMediaLocation,
+  createJoystreamMediaLocation,
+  createLanguage,
+  createVideoMediaEncoding,
+  getClassName,
+  createLicense,
+  createMediaLocation,
+  createBlockOrGetFromDatabase,
+} from './entity/create'
+import { getOrCreate } from './get-or-create'
+
+const debug = Debug('mappings:cd:transaction')
+
+async function getNextEntityId(db: DB): Promise<number> {
+  const e = await db.get(NextEntityId, { where: { id: '1' } })
+  // Entity creation happens before addSchemaSupport so this should never happen
+  if (!e) throw Error(`NextEntityId table doesn't have any record`)
+  return e.nextId
+}
 
 
 // eslint-disable-next-line @typescript-eslint/naming-convention
 // eslint-disable-next-line @typescript-eslint/naming-convention
 export async function contentDirectory_TransactionCompleted(db: DB, event: SubstrateEvent): Promise<void> {
 export async function contentDirectory_TransactionCompleted(db: DB, event: SubstrateEvent): Promise<void> {
@@ -80,11 +103,30 @@ export async function contentDirectory_TransactionCompleted(db: DB, event: Subst
 
 
   // Create entities before adding schema support
   // Create entities before adding schema support
   // We need this to know which entity belongs to which class(we will need to know to update/create
   // We need this to know which entity belongs to which class(we will need to know to update/create
-  // Channel, Video etc.). For example if there is
-  // a property update operation there is no class id
+  // Channel, Video etc.). For example if there is a property update operation there is no class id
   await batchCreateClassEntities(db, block, createEntityOperations)
   await batchCreateClassEntities(db, block, createEntityOperations)
-  await batchUpdatePropertyValue(db, createEntityOperations, updatePropertyValuesOperations)
+
   await batchAddSchemaSupportToEntity(db, createEntityOperations, addSchemaSupportToEntityOperations, block)
   await batchAddSchemaSupportToEntity(db, createEntityOperations, addSchemaSupportToEntityOperations, block)
+
+  await batchUpdatePropertyValue(db, createEntityOperations, updatePropertyValuesOperations)
+}
+
+async function batchCreateClassEntities(db: DB, block: number, operations: ICreateEntityOperation[]): Promise<void> {
+  const nId = await db.get(NextEntityId, { where: { id: '1' } })
+  let nextId = nId ? nId.nextId : 1 // start entity id from 1
+
+  for (const { classId } of operations) {
+    const c = new ClassEntity({
+      id: nextId.toString(), // entity id
+      classId: classId,
+      version: block,
+      happenedIn: await createBlockOrGetFromDatabase(db, block),
+    })
+    await db.save<ClassEntity>(c)
+    nextId++
+  }
+
+  await getOrCreate.nextEntityId(db, nextId)
 }
 }
 
 
 /**
 /**
@@ -100,80 +142,124 @@ async function batchAddSchemaSupportToEntity(
   entities: IEntity[],
   entities: IEntity[],
   block: number
   block: number
 ) {
 ) {
-  // find the related entity ie. Channel, Video etc
-  for (const entity of entities) {
-    const { entityId, indexOf, properties } = entity
-
-    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-    const id = entityId ? entityId.toString() : indexOf!.toString()
+  const classEntityMap: ClassEntityMap = new Map<string, IEntity[]>()
 
 
+  for (const entity of entities) {
     const className = await getClassName(db, entity, createEntityOperations)
     const className = await getClassName(db, entity, createEntityOperations)
-    if (className === undefined) continue
-
-    const arg: IDBBlockId = { db, block, id }
-
-    switch (className) {
-      case ContentDirectoryKnownClasses.CATEGORY:
-        await createCategory(arg, decode.setEntityPropertyValues<ICategory>(properties, CategoryPropertyNamesWithId))
-        break
-
-      case ContentDirectoryKnownClasses.CHANNEL:
-        await createChannel(arg, decode.setEntityPropertyValues<IChannel>(properties, channelPropertyNamesWithId))
-        break
-
-      case ContentDirectoryKnownClasses.KNOWNLICENSE:
-        await createKnownLicense(
-          arg,
-          decode.setEntityPropertyValues<IKnownLicense>(properties, knownLicensePropertyNamesWIthId)
-        )
-        break
-
-      case ContentDirectoryKnownClasses.USERDEFINEDLICENSE:
-        await createUserDefinedLicense(
-          arg,
-          decode.setEntityPropertyValues<IUserDefinedLicense>(properties, userDefinedLicensePropertyNamesWithId)
-        )
-        break
-
-      case ContentDirectoryKnownClasses.JOYSTREAMMEDIALOCATION:
-        await createJoystreamMediaLocation(
-          arg,
-          decode.setEntityPropertyValues<IJoystreamMediaLocation>(properties, joystreamMediaLocationPropertyNamesWithId)
-        )
-        break
-
-      case ContentDirectoryKnownClasses.HTTPMEDIALOCATION:
-        await createHttpMediaLocation(
-          arg,
-          decode.setEntityPropertyValues<IHttpMediaLocation>(properties, httpMediaLocationPropertyNamesWithId)
-        )
-        break
-
-      case ContentDirectoryKnownClasses.VIDEOMEDIA:
-        await createVideoMedia(
-          arg,
-          decode.setEntityPropertyValues<IVideoMedia>(properties, videoMediaPropertyNamesWithId)
-        )
-        break
-
-      case ContentDirectoryKnownClasses.VIDEO:
-        await createVideo(arg, decode.setEntityPropertyValues<IVideo>(properties, videoPropertyNamesWithId))
-        break
-
-      case ContentDirectoryKnownClasses.LANGUAGE:
-        await createLanguage(arg, decode.setEntityPropertyValues<ILanguage>(properties, languagePropertyNamesWIthId))
-        break
-
-      case ContentDirectoryKnownClasses.VIDEOMEDIAENCODING:
-        await createVideoMediaEncoding(
-          arg,
-          decode.setEntityPropertyValues<IVideoMediaEncoding>(properties, videoMediaEncodingPropertyNamesWithId)
-        )
-        break
+    if (className !== undefined) {
+      const es = classEntityMap.get(className)
+      classEntityMap.set(className, es ? [...es, entity] : [entity])
+    }
+  }
 
 
-      default:
-        console.log(`Unknown class name: ${className}`)
-        break
+  // This is a copy of classEntityMap, we will use it to keep track of items.
+  // We will remove items from this list whenever we insert them into db
+  const doneList: ClassEntityMap = new Map(classEntityMap.entries())
+
+  const nextEntityIdBeforeTransaction = (await getNextEntityId(db)) - createEntityOperations.length
+
+  for (const [className, entities] of classEntityMap) {
+    for (const entity of entities) {
+      const { entityId, indexOf, properties } = entity
+      // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+      const id = entityId !== undefined ? entityId : indexOf! + nextEntityIdBeforeTransaction
+      const arg: IDBBlockId = { db, block, id: id.toString() }
+
+      switch (className) {
+        case ContentDirectoryKnownClasses.CATEGORY:
+          await createCategory(arg, decode.setEntityPropertyValues<ICategory>(properties, CategoryPropertyNamesWithId))
+          break
+
+        case ContentDirectoryKnownClasses.CHANNEL:
+          await createChannel(
+            arg,
+            doneList,
+            decode.setEntityPropertyValues<IChannel>(properties, channelPropertyNamesWithId),
+            nextEntityIdBeforeTransaction
+          )
+          break
+
+        case ContentDirectoryKnownClasses.KNOWNLICENSE:
+          await createKnownLicense(
+            arg,
+            decode.setEntityPropertyValues<IKnownLicense>(properties, knownLicensePropertyNamesWIthId)
+          )
+          break
+
+        case ContentDirectoryKnownClasses.USERDEFINEDLICENSE:
+          await createUserDefinedLicense(
+            arg,
+            decode.setEntityPropertyValues<IUserDefinedLicense>(properties, userDefinedLicensePropertyNamesWithId)
+          )
+          break
+
+        case ContentDirectoryKnownClasses.JOYSTREAMMEDIALOCATION:
+          await createJoystreamMediaLocation(
+            arg,
+            decode.setEntityPropertyValues<IJoystreamMediaLocation>(
+              properties,
+              joystreamMediaLocationPropertyNamesWithId
+            )
+          )
+          break
+
+        case ContentDirectoryKnownClasses.HTTPMEDIALOCATION:
+          await createHttpMediaLocation(
+            arg,
+            decode.setEntityPropertyValues<IHttpMediaLocation>(properties, httpMediaLocationPropertyNamesWithId)
+          )
+          break
+
+        case ContentDirectoryKnownClasses.VIDEOMEDIA:
+          await createVideoMedia(
+            arg,
+            doneList,
+            decode.setEntityPropertyValues<IVideoMedia>(properties, videoMediaPropertyNamesWithId),
+            nextEntityIdBeforeTransaction
+          )
+          break
+
+        case ContentDirectoryKnownClasses.VIDEO:
+          await createVideo(
+            arg,
+            doneList,
+            decode.setEntityPropertyValues<IVideo>(properties, videoPropertyNamesWithId),
+            nextEntityIdBeforeTransaction
+          )
+          break
+
+        case ContentDirectoryKnownClasses.LANGUAGE:
+          await createLanguage(arg, decode.setEntityPropertyValues<ILanguage>(properties, languagePropertyNamesWIthId))
+          break
+
+        case ContentDirectoryKnownClasses.VIDEOMEDIAENCODING:
+          await createVideoMediaEncoding(
+            arg,
+            decode.setEntityPropertyValues<IVideoMediaEncoding>(properties, videoMediaEncodingPropertyNamesWithId)
+          )
+          break
+
+        case ContentDirectoryKnownClasses.LICENSE:
+          await createLicense(
+            arg,
+            classEntityMap,
+            decode.setEntityPropertyValues<ILicense>(properties, licensePropertyNamesWithId),
+            nextEntityIdBeforeTransaction
+          )
+          break
+        case ContentDirectoryKnownClasses.MEDIALOCATION:
+          await createMediaLocation(
+            arg,
+            classEntityMap,
+            decode.setEntityPropertyValues<IMediaLocation>(properties, mediaLocationPropertyNamesWithId),
+            nextEntityIdBeforeTransaction
+          )
+          break
+
+        default:
+          console.log(`Unknown class name: ${className}`)
+          break
+      }
     }
     }
   }
   }
 }
 }
@@ -185,12 +271,14 @@ async function batchAddSchemaSupportToEntity(
  * @param entities list of entities those properties values updated
  * @param entities list of entities those properties values updated
  */
  */
 async function batchUpdatePropertyValue(db: DB, createEntityOperations: ICreateEntityOperation[], entities: IEntity[]) {
 async function batchUpdatePropertyValue(db: DB, createEntityOperations: ICreateEntityOperation[], entities: IEntity[]) {
+  const entityIdBeforeTransaction = (await getNextEntityId(db)) - createEntityOperations.length
+
   for (const entity of entities) {
   for (const entity of entities) {
     const { entityId, indexOf, properties } = entity
     const { entityId, indexOf, properties } = entity
     // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
     // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-    const id = entityId ? entityId.toString() : indexOf!.toString()
+    const id = entityId ? entityId.toString() : entityIdBeforeTransaction - indexOf!
 
 
-    const where: IWhereCond = { where: { id } }
+    const where: IWhereCond = { where: { id: id.toString() } }
     const className = await getClassName(db, entity, createEntityOperations)
     const className = await getClassName(db, entity, createEntityOperations)
     if (className === undefined) {
     if (className === undefined) {
       console.log(`Can not update entity properties values. Unknown class name`)
       console.log(`Can not update entity properties values. Unknown class name`)
@@ -199,10 +287,11 @@ async function batchUpdatePropertyValue(db: DB, createEntityOperations: ICreateE
 
 
     switch (className) {
     switch (className) {
       case ContentDirectoryKnownClasses.CHANNEL:
       case ContentDirectoryKnownClasses.CHANNEL:
-        updateChannelEntityPropertyValues(
+        await updateChannelEntityPropertyValues(
           db,
           db,
           where,
           where,
-          decode.setEntityPropertyValues<IChannel>(properties, CategoryPropertyNamesWithId)
+          decode.setEntityPropertyValues<IChannel>(properties, channelPropertyNamesWithId),
+          entityIdBeforeTransaction
         )
         )
         break
         break
 
 
@@ -250,7 +339,8 @@ async function batchUpdatePropertyValue(db: DB, createEntityOperations: ICreateE
         await updateVideoMediaEntityPropertyValues(
         await updateVideoMediaEntityPropertyValues(
           db,
           db,
           where,
           where,
-          decode.setEntityPropertyValues<IVideoMedia>(properties, videoPropertyNamesWithId)
+          decode.setEntityPropertyValues<IVideoMedia>(properties, videoPropertyNamesWithId),
+          entityIdBeforeTransaction
         )
         )
         break
         break
 
 
@@ -258,7 +348,8 @@ async function batchUpdatePropertyValue(db: DB, createEntityOperations: ICreateE
         await updateVideoEntityPropertyValues(
         await updateVideoEntityPropertyValues(
           db,
           db,
           where,
           where,
-          decode.setEntityPropertyValues<IVideo>(properties, videoPropertyNamesWithId)
+          decode.setEntityPropertyValues<IVideo>(properties, videoPropertyNamesWithId),
+          entityIdBeforeTransaction
         )
         )
         break
         break
 
 
@@ -277,6 +368,22 @@ async function batchUpdatePropertyValue(db: DB, createEntityOperations: ICreateE
           decode.setEntityPropertyValues<IVideoMediaEncoding>(properties, videoMediaEncodingPropertyNamesWithId)
           decode.setEntityPropertyValues<IVideoMediaEncoding>(properties, videoMediaEncodingPropertyNamesWithId)
         )
         )
         break
         break
+      case ContentDirectoryKnownClasses.LICENSE:
+        await updateLicenseEntityPropertyValues(
+          db,
+          where,
+          decode.setEntityPropertyValues<ILicense>(properties, licensePropertyNamesWithId),
+          entityIdBeforeTransaction
+        )
+        break
+      case ContentDirectoryKnownClasses.MEDIALOCATION:
+        await updateMediaLocationEntityPropertyValues(
+          db,
+          where,
+          decode.setEntityPropertyValues<IMediaLocation>(properties, mediaLocationPropertyNamesWithId),
+          entityIdBeforeTransaction
+        )
+        break
 
 
       default:
       default:
         console.log(`Unknown class name: ${className}`)
         console.log(`Unknown class name: ${className}`)

+ 35 - 11
query-node/mappings/types.ts

@@ -34,6 +34,11 @@ export interface MemberControllerAccount extends BaseJoystreamMember {
   controllerAccount: Buffer
   controllerAccount: Buffer
 }
 }
 
 
+export interface IReference {
+  entityId: number
+  existing: boolean
+}
+
 export interface IChannel {
 export interface IChannel {
   title: string
   title: string
   description: string
   description: string
@@ -41,7 +46,7 @@ export interface IChannel {
   avatarPhotoURL: string
   avatarPhotoURL: string
   isPublic: boolean
   isPublic: boolean
   isCurated: boolean
   isCurated: boolean
-  language: number
+  language?: IReference
 }
 }
 
 
 export interface ICategory {
 export interface ICategory {
@@ -79,32 +84,42 @@ export interface IVideoMediaEncoding {
 }
 }
 
 
 export interface IVideoMedia {
 export interface IVideoMedia {
-  encoding: number
+  encoding?: IReference
   pixelWidth: number
   pixelWidth: number
   pixelHeight: number
   pixelHeight: number
   size: number
   size: number
-  location: number
+  location?: IReference
 }
 }
 
 
 export interface IVideo {
 export interface IVideo {
   // referenced entity's id
   // referenced entity's id
-  channel: number
+  channel?: IReference
   // referenced entity's id
   // referenced entity's id
-  category: number
+  category?: IReference
   title: string
   title: string
   description: string
   description: string
   duration: number
   duration: number
   skippableIntroDuration?: number
   skippableIntroDuration?: number
   thumbnailURL: string
   thumbnailURL: string
-  language: number
+  language?: IReference
   // referenced entity's id
   // referenced entity's id
-  media: number
+  media?: IReference
   hasMarketing?: boolean
   hasMarketing?: boolean
   publishedBeforeJoystream?: number
   publishedBeforeJoystream?: number
   isPublic: boolean
   isPublic: boolean
   isCurated: boolean
   isCurated: boolean
   isExplicit: boolean
   isExplicit: boolean
-  license: number
+  license?: IReference
+}
+
+export interface ILicense {
+  knownLicense?: IReference
+  userDefinedLicense?: IReference
+}
+
+export interface IMediaLocation {
+  httpMediaLocation?: IReference
+  joystreamMediaLocation?: IReference
 }
 }
 
 
 export enum OperationType {
 export enum OperationType {
@@ -135,9 +150,15 @@ export interface IBatchOperation {
 }
 }
 
 
 export interface IProperty {
 export interface IProperty {
-  [propertyId: string]: any
-  // propertyId: string;
-  // value: any;
+  // PropertId: Value
+  // [propertyId: string]: any
+
+  id: string
+  value: any
+
+  // If reference.exising is false then reference.entityId is the index that entity is at
+  // in the transaction batch operation
+  reference?: IReference
 }
 }
 
 
 export interface IEntity {
 export interface IEntity {
@@ -166,5 +187,8 @@ export interface ICreateEntityOperation {
 export interface IDBBlockId {
 export interface IDBBlockId {
   db: DB
   db: DB
   block: number
   block: number
+  // Entity id
   id: string
   id: string
 }
 }
+
+export type ClassEntityMap = Map<string, IEntity[]>

+ 3 - 2
query-node/package.json

@@ -19,12 +19,13 @@
 		"codegen:all": "yarn hydra-cli codegen && cp indexer-tsconfig.json generated/indexer/tsconfig.json",
 		"codegen:all": "yarn hydra-cli codegen && cp indexer-tsconfig.json generated/indexer/tsconfig.json",
 		"codegen:indexer": "yarn hydra-cli codegen --no-graphql && cp indexer-tsconfig.json generated/indexer/tsconfig.json",
 		"codegen:indexer": "yarn hydra-cli codegen --no-graphql && cp indexer-tsconfig.json generated/indexer/tsconfig.json",
 		"codegen:server": "yarn hydra-cli codegen --no-indexer",
 		"codegen:server": "yarn hydra-cli codegen --no-indexer",
-		"docker:up": "docker-compose up -d"
+		"docker:up": "docker-compose up -d",
+    "cd-classes": "ts-node scripts/get-class-id-and-name.ts"
 	},
 	},
 	"author": "",
 	"author": "",
 	"license": "ISC",
 	"license": "ISC",
 	"devDependencies": {
 	"devDependencies": {
-		"@dzlzv/hydra-cli": "^0.0.17"
+		"@dzlzv/hydra-cli": "^0.0.19"
 	},
 	},
 	"dependencies": {
 	"dependencies": {
 		"@joystream/types": "^0.14.0",
 		"@joystream/types": "^0.14.0",

+ 56 - 18
query-node/schema.graphql

@@ -8,8 +8,8 @@ type Block @entity {
   "Block number as a string"
   "Block number as a string"
   id: ID!
   id: ID!
   block: Int!
   block: Int!
-  timestamp: Int!
-  nework: Network!
+  timestamp: BigInt!
+  network: Network!
 }
 }
 
 
 "Stored information about a registered user"
 "Stored information about a registered user"
@@ -55,6 +55,14 @@ type ClassEntity @entity {
   happenedIn: Block!
   happenedIn: Block!
 }
 }
 
 
+"Keep track of the next entity id"
+type NextEntityId @entity {
+  "Constant field is set to '1'"
+  id: ID!
+
+  nextId: Int!
+}
+
 #### High Level Derivative Entities ####
 #### High Level Derivative Entities ####
 
 
 type Language @entity {
 type Language @entity {
@@ -94,9 +102,9 @@ type Channel @entity {
   isCurated: Boolean!
   isCurated: Boolean!
 
 
   "The primary langauge of the channel's content"
   "The primary langauge of the channel's content"
-  languageId: Int
+  language: Language!
 
 
-  # videos: [Video!] @derivedFrom(field: "channel")
+  videos: [Video!] @derivedFrom(field: "channel")
 
 
   happenedIn: Block!
   happenedIn: Block!
 }
 }
@@ -111,7 +119,7 @@ type Category @entity {
   "The description of the category"
   "The description of the category"
   description: String
   description: String
 
 
-  # videos: [Video!] @derivedFrom(field: "category")
+  videos: [Video!] @derivedFrom(field: "category")
 
 
   happenedIn: Block!
   happenedIn: Block!
 }
 }
@@ -122,6 +130,8 @@ type VideoMediaEncoding @entity {
   id: ID!
   id: ID!
 
 
   name: String!
   name: String!
+
+  happenedIn: Block!
 }
 }
 
 
 type KnownLicense @entity {
 type KnownLicense @entity {
@@ -153,6 +163,38 @@ type UserDefinedLicense @entity {
   happenedIn: Block!
   happenedIn: Block!
 }
 }
 
 
+type License @entity {
+  "Runtime entity identifier (EntityId)"
+  id: ID!
+
+  # One of the following field will be non-null
+
+  "Reference to a known license"
+  knownLicense: KnownLicense
+
+  "Reference to user-defined license"
+  userdefinedLicense: UserDefinedLicense
+
+  happenedIn: Block!
+}
+
+type MediaLocation @entity {
+  "Runtime entity identifier (EntityId)"
+  id: ID!
+
+  # One of the following field will be non-null
+
+  "A reference to HttpMediaLocation"
+  httpMediaLocation: HttpMediaLocation
+
+  "A reference to JoystreamMediaLocation"
+  joystreamMediaLocation: JoystreamMediaLocation
+
+  videoMedia: VideoMedia @derivedFrom(field: "location")
+
+  happenedIn: Block!
+}
+
 type JoystreamMediaLocation @entity {
 type JoystreamMediaLocation @entity {
   "Runtime entity identifier (EntityId)"
   "Runtime entity identifier (EntityId)"
   id: ID!
   id: ID!
@@ -181,7 +223,7 @@ type VideoMedia @entity {
   id: ID!
   id: ID!
 
 
   "Encoding of the video media object"
   "Encoding of the video media object"
-  encodingId: Int!
+  encoding: VideoMediaEncoding!
 
 
   "Video media width in pixels"
   "Video media width in pixels"
   pixelWidth: Int!
   pixelWidth: Int!
@@ -192,13 +234,10 @@ type VideoMedia @entity {
   "Video media size in bytes"
   "Video media size in bytes"
   size: Int
   size: Int
 
 
-  # video: Video! @derivedFrom(field: "media")
-
-  # One of the location field will be non-null
+  video: Video @derivedFrom(field: "media")
 
 
-  # httpMediaLocation: HttpMediaLocation
-  # joystreamMediaLocation: JoystreamMediaLocation
-  locationId: Int!
+  "Location of the video media object"
+  location: MediaLocation!
 
 
   happenedIn: Block!
   happenedIn: Block!
 }
 }
@@ -208,10 +247,10 @@ type Video @entity {
   id: ID!
   id: ID!
 
 
   "Reference to member's channel"
   "Reference to member's channel"
-  channelId: Int!
+  channel: Channel!
 
 
   "Reference to a video category"
   "Reference to a video category"
-  categoryId: Int!
+  category: Category!
 
 
   "The title of the video"
   "The title of the video"
   title: String! @fulltext(query: "titles")
   title: String! @fulltext(query: "titles")
@@ -229,10 +268,10 @@ type Video @entity {
   thumbnailURL: String!
   thumbnailURL: String!
 
 
   "Video's main langauge"
   "Video's main langauge"
-  languageId: Int
+  language: Language
 
 
   "Reference to VideoMedia"
   "Reference to VideoMedia"
-  videoMediaId: Int!
+  media: VideoMedia!
 
 
   "Whether or not Video contains marketing"
   "Whether or not Video contains marketing"
   hasMarketing: Boolean
   hasMarketing: Boolean
@@ -249,8 +288,7 @@ type Video @entity {
   "Whether the Video contains explicit material."
   "Whether the Video contains explicit material."
   isExplicit: Boolean!
   isExplicit: Boolean!
 
 
-  # Lincense
-  licenseId: Int!
+  license: License!
 
 
   happenedIn: Block!
   happenedIn: Block!
 }
 }

+ 21 - 0
query-node/scripts/get-class-id-and-name.ts

@@ -0,0 +1,21 @@
+import { ApiPromise, WsProvider } from '@polkadot/api'
+import { types as joyTypes } from '@joystream/types'
+import * as BN from 'bn.js'
+
+async function main() {
+  // Initialize the api
+  const provider = new WsProvider('ws://127.0.0.1:9944')
+  const api = await ApiPromise.create({ provider, types: joyTypes })
+
+  const n = await api.query.contentDirectory.nextClassId()
+  const nextClassId = new BN(n.toJSON() as string).toNumber()
+  for (let id = 0; id < nextClassId; id++) {
+    const cls = await api.query.contentDirectory.classById(new BN(id))
+    const { name } = cls.toJSON() as never
+    console.log(id, name)
+  }
+}
+
+main()
+  .then(() => process.exit())
+  .catch(console.error)

+ 7 - 7
runtime-modules/common/Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 [package]
 name = 'pallet-common'
 name = 'pallet-common'
-version = '3.0.0'
+version = '3.1.0'
 authors = ['Joystream contributors']
 authors = ['Joystream contributors']
 edition = '2018'
 edition = '2018'
 
 
@@ -8,11 +8,11 @@ edition = '2018'
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
 strum = {version = "0.19", optional = true}
 strum = {version = "0.19", optional = true}
 strum_macros = {version = "0.19", optional = true}
 strum_macros = {version = "0.19", optional = true}
-codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
-sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+codec = { package = 'parity-scale-codec', version = '1.3.4', default-features = false, features = ['derive'] }
+sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 
 
 [features]
 [features]
 default = ['std']
 default = ['std']
@@ -23,6 +23,6 @@ std = [
 	'codec/std',
 	'codec/std',
 	'sp-runtime/std',
 	'sp-runtime/std',
 	'frame-support/std',
 	'frame-support/std',
-	'system/std',
+	'frame-system/std',
 	'pallet-timestamp/std',
 	'pallet-timestamp/std',
 ]
 ]

+ 4 - 3
runtime-modules/common/src/currency.rs

@@ -1,14 +1,15 @@
 use frame_support::traits::{Currency, LockableCurrency, ReservableCurrency};
 use frame_support::traits::{Currency, LockableCurrency, ReservableCurrency};
 use sp_runtime::traits::Convert;
 use sp_runtime::traits::Convert;
 
 
-pub trait GovernanceCurrency: system::Trait + Sized {
+pub trait GovernanceCurrency: frame_system::Trait + Sized {
     type Currency: Currency<Self::AccountId>
     type Currency: Currency<Self::AccountId>
         + ReservableCurrency<Self::AccountId>
         + ReservableCurrency<Self::AccountId>
         + LockableCurrency<Self::AccountId, Moment = Self::BlockNumber>;
         + LockableCurrency<Self::AccountId, Moment = Self::BlockNumber>;
 }
 }
 
 
-pub type BalanceOf<T> =
-    <<T as GovernanceCurrency>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
+pub type BalanceOf<T> = <<T as GovernanceCurrency>::Currency as Currency<
+    <T as frame_system::Trait>::AccountId,
+>>::Balance;
 
 
 /// A structure that converts the currency type into a lossy u64
 /// A structure that converts the currency type into a lossy u64
 /// And back from u128
 /// And back from u128

+ 2 - 2
runtime-modules/common/src/lib.rs

@@ -24,10 +24,10 @@ pub struct BlockAndTime<BlockNumber, Moment> {
 /// Gathers current block and time information for the runtime.
 /// Gathers current block and time information for the runtime.
 /// If this function is used inside a config() at genesis the timestamp will be 0
 /// If this function is used inside a config() at genesis the timestamp will be 0
 /// because the timestamp is actually produced by validators.
 /// because the timestamp is actually produced by validators.
-pub fn current_block_time<T: system::Trait + pallet_timestamp::Trait>(
+pub fn current_block_time<T: frame_system::Trait + pallet_timestamp::Trait>(
 ) -> BlockAndTime<T::BlockNumber, T::Moment> {
 ) -> BlockAndTime<T::BlockNumber, T::Moment> {
     BlockAndTime {
     BlockAndTime {
-        block: <system::Module<T>>::block_number(),
+        block: <frame_system::Module<T>>::block_number(),
         time: <pallet_timestamp::Module<T>>::now(),
         time: <pallet_timestamp::Module<T>>::now(),
     }
     }
 }
 }

+ 3 - 3
runtime-modules/common/src/origin.rs

@@ -1,4 +1,4 @@
-use system::RawOrigin;
+use frame_system::RawOrigin;
 
 
 /// Abstract validator for the origin(account_id) and actor_id (eg.: thread author id).
 /// Abstract validator for the origin(account_id) and actor_id (eg.: thread author id).
 pub trait ActorOriginValidator<Origin, ActorId, AccountId> {
 pub trait ActorOriginValidator<Origin, ActorId, AccountId> {
@@ -8,9 +8,9 @@ pub trait ActorOriginValidator<Origin, ActorId, AccountId> {
 
 
 // TODO: delete when T::Origin will support the clone()
 // TODO: delete when T::Origin will support the clone()
 /// Multiplies the T::Origin.
 /// Multiplies the T::Origin.
-/// In our current substrate version system::Origin doesn't support clone(),
+/// In our current substrate version frame_system::Origin doesn't support clone(),
 /// but it will be supported in latest up-to-date substrate version.
 /// but it will be supported in latest up-to-date substrate version.
-pub fn double_origin<T: system::Trait>(origin: T::Origin) -> (T::Origin, T::Origin) {
+pub fn double_origin<T: frame_system::Trait>(origin: T::Origin) -> (T::Origin, T::Origin) {
     let coerced_origin = origin.into().ok().unwrap_or(RawOrigin::None);
     let coerced_origin = origin.into().ok().unwrap_or(RawOrigin::None);
 
 
     let (cloned_origin1, cloned_origin2) = match coerced_origin {
     let (cloned_origin1, cloned_origin2) = match coerced_origin {

+ 10 - 10
runtime-modules/content-directory/Cargo.toml

@@ -1,21 +1,21 @@
 [package]
 [package]
 name = 'pallet-content-directory'
 name = 'pallet-content-directory'
-version = '3.0.0'
+version = '3.1.0'
 authors = ['Joystream contributors']
 authors = ['Joystream contributors']
 edition = '2018'
 edition = '2018'
 
 
 [dependencies]
 [dependencies]
-sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
+sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+codec = { package = 'parity-scale-codec', version = '1.3.4', default-features = false, features = ['derive'] }
 serde = {version = '1.0.101', features = ['derive'], optional = true}
 serde = {version = '1.0.101', features = ['derive'], optional = true}
 
 
 [dev-dependencies]
 [dev-dependencies]
-sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 
 
 [features]
 [features]
 default = ['std']
 default = ['std']
@@ -23,7 +23,7 @@ std = [
 	'sp-std/std',
 	'sp-std/std',
 	'sp-runtime/std',
 	'sp-runtime/std',
 	'frame-support/std',
 	'frame-support/std',
-	'system/std',
+	'frame-system/std',
 	'sp-arithmetic/std',
 	'sp-arithmetic/std',
 	'codec/std',
 	'codec/std',
 	'serde',
 	'serde',

+ 10 - 7
runtime-modules/content-directory/src/lib.rs

@@ -95,7 +95,7 @@
 //!
 //!
 //! ```
 //! ```
 //! use frame_support::{decl_module, assert_ok};
 //! use frame_support::{decl_module, assert_ok};
-//! use system::{self as system, ensure_signed};
+//! use frame_system::{self as system, ensure_signed};
 //!
 //!
 //! pub trait Trait: pallet_content_directory::Trait {}
 //! pub trait Trait: pallet_content_directory::Trait {}
 //!
 //!
@@ -144,6 +144,7 @@ use frame_support::storage::IterableStorageMap;
 use frame_support::{
 use frame_support::{
     decl_event, decl_module, decl_storage, dispatch::DispatchResult, ensure, traits::Get, Parameter,
     decl_event, decl_module, decl_storage, dispatch::DispatchResult, ensure, traits::Get, Parameter,
 };
 };
+use frame_system::ensure_signed;
 #[cfg(feature = "std")]
 #[cfg(feature = "std")]
 pub use serde::{Deserialize, Serialize};
 pub use serde::{Deserialize, Serialize};
 use sp_arithmetic::traits::{BaseArithmetic, One, Zero};
 use sp_arithmetic::traits::{BaseArithmetic, One, Zero};
@@ -152,7 +153,6 @@ use sp_std::borrow::ToOwned;
 use sp_std::collections::{btree_map::BTreeMap, btree_set::BTreeSet};
 use sp_std::collections::{btree_map::BTreeMap, btree_set::BTreeSet};
 use sp_std::vec;
 use sp_std::vec;
 use sp_std::vec::Vec;
 use sp_std::vec::Vec;
-use system::ensure_signed;
 
 
 pub use errors::Error;
 pub use errors::Error;
 
 
@@ -165,7 +165,7 @@ pub type MaxNumber = u32;
 pub type EntityOf<T> = Entity<
 pub type EntityOf<T> = Entity<
     <T as Trait>::ClassId,
     <T as Trait>::ClassId,
     <T as ActorAuthenticator>::MemberId,
     <T as ActorAuthenticator>::MemberId,
-    <T as system::Trait>::Hash,
+    <T as frame_system::Trait>::Hash,
     <T as Trait>::EntityId,
     <T as Trait>::EntityId,
     <T as Trait>::Nonce,
     <T as Trait>::Nonce,
 >;
 >;
@@ -175,13 +175,16 @@ pub type ClassOf<T> =
     Class<<T as Trait>::EntityId, <T as Trait>::ClassId, <T as ActorAuthenticator>::CuratorGroupId>;
     Class<<T as Trait>::EntityId, <T as Trait>::ClassId, <T as ActorAuthenticator>::CuratorGroupId>;
 
 
 /// Type simplification
 /// Type simplification
-pub type StoredPropertyValueOf<T> =
-    StoredPropertyValue<<T as system::Trait>::Hash, <T as Trait>::EntityId, <T as Trait>::Nonce>;
+pub type StoredPropertyValueOf<T> = StoredPropertyValue<
+    <T as frame_system::Trait>::Hash,
+    <T as Trait>::EntityId,
+    <T as Trait>::Nonce,
+>;
 
 
 /// Module configuration trait for this Substrate module.
 /// Module configuration trait for this Substrate module.
-pub trait Trait: system::Trait + ActorAuthenticator + Clone {
+pub trait Trait: frame_system::Trait + ActorAuthenticator + Clone {
     /// The overarching event type.
     /// The overarching event type.
-    type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
+    type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
 
 
     /// Nonce type is used to avoid data race update conditions, when performing property value vector operations
     /// Nonce type is used to avoid data race update conditions, when performing property value vector operations
     type Nonce: Parameter
     type Nonce: Parameter

+ 7 - 6
runtime-modules/content-directory/src/mock.rs

@@ -20,7 +20,7 @@ use std::cell::RefCell;
 pub type ClassId = <Runtime as Trait>::ClassId;
 pub type ClassId = <Runtime as Trait>::ClassId;
 pub type EntityId = <Runtime as Trait>::EntityId;
 pub type EntityId = <Runtime as Trait>::EntityId;
 pub type Nonce = <Runtime as Trait>::Nonce;
 pub type Nonce = <Runtime as Trait>::Nonce;
-pub type Hashed = <Runtime as system::Trait>::Hash;
+pub type Hashed = <Runtime as frame_system::Trait>::Hash;
 
 
 pub type CuratorId = <Runtime as ActorAuthenticator>::CuratorId;
 pub type CuratorId = <Runtime as ActorAuthenticator>::CuratorId;
 pub type CuratorGroupId = <Runtime as ActorAuthenticator>::CuratorGroupId;
 pub type CuratorGroupId = <Runtime as ActorAuthenticator>::CuratorGroupId;
@@ -208,7 +208,7 @@ impl Get<EntityId> for IndividualEntitiesCreationLimit {
     }
     }
 }
 }
 
 
-impl system::Trait for Runtime {
+impl frame_system::Trait for Runtime {
     type BaseCallFilter = ();
     type BaseCallFilter = ();
     type Origin = Origin;
     type Origin = Origin;
     type Call = ();
     type Call = ();
@@ -229,10 +229,11 @@ impl system::Trait for Runtime {
     type MaximumBlockLength = MaximumBlockLength;
     type MaximumBlockLength = MaximumBlockLength;
     type AvailableBlockRatio = AvailableBlockRatio;
     type AvailableBlockRatio = AvailableBlockRatio;
     type Version = ();
     type Version = ();
-    type ModuleToIndex = ();
+    type PalletInfo = ();
     type AccountData = ();
     type AccountData = ();
     type OnNewAccount = ();
     type OnNewAccount = ();
     type OnKilledAccount = ();
     type OnKilledAccount = ();
+    type SystemWeightInfo = ();
 }
 }
 
 
 mod test_events {
 mod test_events {
@@ -242,7 +243,7 @@ mod test_events {
 impl_outer_event! {
 impl_outer_event! {
     pub enum TestEvent for Runtime {
     pub enum TestEvent for Runtime {
         test_events<T>,
         test_events<T>,
-        system<T>,
+        frame_system<T>,
     }
     }
 }
 }
 
 
@@ -364,7 +365,7 @@ impl ExtBuilder {
 
 
     pub fn build(self, config: GenesisConfig<Runtime>) -> sp_io::TestExternalities {
     pub fn build(self, config: GenesisConfig<Runtime>) -> sp_io::TestExternalities {
         self.set_associated_consts();
         self.set_associated_consts();
-        let mut t = system::GenesisConfig::default()
+        let mut t = frame_system::GenesisConfig::default()
             .build_storage::<Runtime>()
             .build_storage::<Runtime>()
             .unwrap();
             .unwrap();
         config.assimilate_storage(&mut t).unwrap();
         config.assimilate_storage(&mut t).unwrap();
@@ -1024,7 +1025,7 @@ impl PropertyLockingPolicy {
 }
 }
 
 
 // Assign back to type variables so we can make dispatched calls of these modules later.
 // Assign back to type variables so we can make dispatched calls of these modules later.
-pub type System = system::Module<Runtime>;
+pub type System = frame_system::Module<Runtime>;
 pub type TestModule = Module<Runtime>;
 pub type TestModule = Module<Runtime>;
 
 
 // Recommendation from Parity on testing on_finalize
 // Recommendation from Parity on testing on_finalize

+ 1 - 1
runtime-modules/content-directory/src/permissions.rs

@@ -19,7 +19,7 @@ use sp_arithmetic::traits::BaseArithmetic;
 use sp_runtime::traits::{MaybeSerializeDeserialize, Member};
 use sp_runtime::traits::{MaybeSerializeDeserialize, Member};
 
 
 /// Model of authentication manager.
 /// Model of authentication manager.
-pub trait ActorAuthenticator: system::Trait {
+pub trait ActorAuthenticator: frame_system::Trait {
     /// Curator identifier
     /// Curator identifier
     type CuratorId: Parameter
     type CuratorId: Parameter
         + Member
         + Member

+ 2 - 2
runtime-modules/content-directory/src/schema/convert.rs

@@ -29,7 +29,7 @@ impl<T: Trait> From<InputValue<T>> for StoredValue<T::Hash, T::EntityId> {
             InputValue::Text(value) => StoredValue::Text(value),
             InputValue::Text(value) => StoredValue::Text(value),
 
 
             InputValue::TextToHash(value) => {
             InputValue::TextToHash(value) => {
-                let hash_value = value.using_encoded(<T as system::Trait>::Hashing::hash);
+                let hash_value = value.using_encoded(<T as frame_system::Trait>::Hashing::hash);
                 StoredValue::Hash(hash_value)
                 StoredValue::Hash(hash_value)
             }
             }
             InputValue::Reference(value) => StoredValue::Reference(value),
             InputValue::Reference(value) => StoredValue::Reference(value),
@@ -52,7 +52,7 @@ impl<T: Trait> From<VecInputValue<T>> for VecStoredValue<T::Hash, T::EntityId> {
             VecInputValue::TextToHash(vec_value) => {
             VecInputValue::TextToHash(vec_value) => {
                 let hash_vec_value: Vec<_> = vec_value
                 let hash_vec_value: Vec<_> = vec_value
                     .into_iter()
                     .into_iter()
-                    .map(|value| value.using_encoded(<T as system::Trait>::Hashing::hash))
+                    .map(|value| value.using_encoded(<T as frame_system::Trait>::Hashing::hash))
                     .collect();
                     .collect();
                 VecStoredValue::Hash(hash_vec_value)
                 VecStoredValue::Hash(hash_vec_value)
             }
             }

+ 2 - 2
runtime-modules/content-directory/src/schema/output.rs

@@ -81,7 +81,7 @@ impl<
     pub fn compute_unique_hash<T: Trait>(&self, property_id: PropertyId) -> T::Hash {
     pub fn compute_unique_hash<T: Trait>(&self, property_id: PropertyId) -> T::Hash {
         match self {
         match self {
             StoredPropertyValue::Single(output_value) => {
             StoredPropertyValue::Single(output_value) => {
-                (property_id, output_value).using_encoded(<T as system::Trait>::Hashing::hash)
+                (property_id, output_value).using_encoded(<T as frame_system::Trait>::Hashing::hash)
             }
             }
             StoredPropertyValue::Vector(vector_output_value) => {
             StoredPropertyValue::Vector(vector_output_value) => {
                 vector_output_value.compute_unique_hash::<T>(property_id)
                 vector_output_value.compute_unique_hash::<T>(property_id)
@@ -159,7 +159,7 @@ impl<
     /// Compute hash from unique vec property value and its respective property_id
     /// Compute hash from unique vec property value and its respective property_id
     pub fn compute_unique_hash<T: Trait>(&self, property_id: PropertyId) -> T::Hash {
     pub fn compute_unique_hash<T: Trait>(&self, property_id: PropertyId) -> T::Hash {
         // Do not hash nonce
         // Do not hash nonce
-        (property_id, &self.vec_value).using_encoded(<T as system::Trait>::Hashing::hash)
+        (property_id, &self.vec_value).using_encoded(<T as frame_system::Trait>::Hashing::hash)
     }
     }
 
 
     /// Increase nonce by 1
     /// Increase nonce by 1

+ 12 - 12
runtime-modules/content-working-group/Cargo.toml

@@ -1,17 +1,17 @@
 [package]
 [package]
 name = 'pallet-content-working-group'
 name = 'pallet-content-working-group'
-version = '3.0.0'
+version = '3.1.0'
 authors = ['Joystream contributors']
 authors = ['Joystream contributors']
 edition = '2018'
 edition = '2018'
 
 
 [dependencies]
 [dependencies]
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
-codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
-sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+codec = { package = 'parity-scale-codec', version = '1.3.4', default-features = false, features = ['derive'] }
+sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 membership = { package = 'pallet-membership', default-features = false, path = '../membership'}
 membership = { package = 'pallet-membership', default-features = false, path = '../membership'}
 stake = { package = 'pallet-stake', default-features = false, path = '../stake'}
 stake = { package = 'pallet-stake', default-features = false, path = '../stake'}
 hiring = { package = 'pallet-hiring', default-features = false, path = '../hiring'}
 hiring = { package = 'pallet-hiring', default-features = false, path = '../hiring'}
@@ -22,10 +22,10 @@ versioned_store_permissions = { package = 'pallet-versioned-store-permissions',
 common = { package = 'pallet-common', default-features = false, path = '../common'}
 common = { package = 'pallet-common', default-features = false, path = '../common'}
 
 
 [dev-dependencies]
 [dev-dependencies]
-sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 
 
 [features]
 [features]
 default = ['std']
 default = ['std']
@@ -34,7 +34,7 @@ std = [
 	'codec/std',
 	'codec/std',
 	'sp-std/std',
 	'sp-std/std',
 	'frame-support/std',
 	'frame-support/std',
-	'system/std',
+	'frame-system/std',
 	'sp-arithmetic/std',
 	'sp-arithmetic/std',
 	'sp-runtime/std',
 	'sp-runtime/std',
 	'membership/std',
 	'membership/std',

+ 15 - 17
runtime-modules/content-working-group/src/lib.rs

@@ -22,18 +22,18 @@ use serde::{Deserialize, Serialize};
 use codec::{Decode, Encode};
 use codec::{Decode, Encode};
 use frame_support::traits::{Currency, ExistenceRequirement, WithdrawReasons};
 use frame_support::traits::{Currency, ExistenceRequirement, WithdrawReasons};
 use frame_support::{decl_event, decl_module, decl_storage, ensure};
 use frame_support::{decl_event, decl_module, decl_storage, ensure};
+use frame_system::{ensure_root, ensure_signed};
 use sp_arithmetic::traits::{One, Zero};
 use sp_arithmetic::traits::{One, Zero};
 use sp_std::borrow::ToOwned;
 use sp_std::borrow::ToOwned;
 use sp_std::collections::{btree_map::BTreeMap, btree_set::BTreeSet};
 use sp_std::collections::{btree_map::BTreeMap, btree_set::BTreeSet};
 use sp_std::vec;
 use sp_std::vec;
 use sp_std::vec::Vec;
 use sp_std::vec::Vec;
-use system::{ensure_root, ensure_signed};
 
 
 use common::constraints::InputValidationLengthConstraint;
 use common::constraints::InputValidationLengthConstraint;
 
 
 /// Module configuration trait for this Substrate module.
 /// Module configuration trait for this Substrate module.
 pub trait Trait:
 pub trait Trait:
-    system::Trait
+    frame_system::Trait
     + minting::Trait
     + minting::Trait
     + recurringrewards::Trait
     + recurringrewards::Trait
     + stake::Trait
     + stake::Trait
@@ -42,7 +42,7 @@ pub trait Trait:
     + membership::Trait
     + membership::Trait
 {
 {
     /// The event type.
     /// The event type.
-    type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
+    type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
 }
 }
 
 
 /// Type constraint for identifer used for actors.
 /// Type constraint for identifer used for actors.
@@ -67,14 +67,15 @@ pub type CuratorApplicationId<T> = <T as hiring::Trait>::ApplicationId;
 
 
 /// Balance type of runtime
 /// Balance type of runtime
 pub type BalanceOf<T> =
 pub type BalanceOf<T> =
-    <<T as stake::Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
+    <<T as stake::Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
 
 
 /// Balance type of runtime
 /// Balance type of runtime
 pub type CurrencyOf<T> = <T as stake::Trait>::Currency;
 pub type CurrencyOf<T> = <T as stake::Trait>::Currency;
 
 
 /// Negative imbalance of runtime.
 /// Negative imbalance of runtime.
-pub type NegativeImbalance<T> =
-    <<T as stake::Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;
+pub type NegativeImbalance<T> = <<T as stake::Trait>::Currency as Currency<
+    <T as frame_system::Trait>::AccountId,
+>>::NegativeImbalance;
 
 
 /// Type of mintin reward relationship identifiers
 /// Type of mintin reward relationship identifiers
 pub type RewardRelationshipId<T> = <T as recurringrewards::Trait>::RewardRelationshipId;
 pub type RewardRelationshipId<T> = <T as recurringrewards::Trait>::RewardRelationshipId;
@@ -1061,7 +1062,7 @@ decl_event! {
         CuratorId = CuratorId<T>,
         CuratorId = CuratorId<T>,
         CuratorApplicationIdToCuratorIdMap = CuratorApplicationIdToCuratorIdMap<T>,
         CuratorApplicationIdToCuratorIdMap = CuratorApplicationIdToCuratorIdMap<T>,
         MintBalanceOf = minting::BalanceOf<T>,
         MintBalanceOf = minting::BalanceOf<T>,
-        <T as system::Trait>::AccountId,
+        <T as frame_system::Trait>::AccountId,
         <T as minting::Trait>::MintId,
         <T as minting::Trait>::MintId,
     {
     {
         ChannelCreated(ChannelId),
         ChannelCreated(ChannelId),
@@ -1160,7 +1161,7 @@ decl_module! {
                 role_account,
                 role_account,
                 publication_status,
                 publication_status,
                 curation_status: ChannelCurationStatus::Normal,
                 curation_status: ChannelCurationStatus::Normal,
-                created: <system::Module<T>>::block_number(),
+                created: <frame_system::Module<T>>::block_number(),
                 principal_id,
                 principal_id,
             };
             };
 
 
@@ -1421,7 +1422,7 @@ decl_module! {
                 ensure!(<minting::Mints<T>>::contains_key(mint_id), MSG_FILL_CURATOR_OPENING_MINT_DOES_NOT_EXIST);
                 ensure!(<minting::Mints<T>>::contains_key(mint_id), MSG_FILL_CURATOR_OPENING_MINT_DOES_NOT_EXIST);
 
 
                 // Make sure valid parameters are selected for next payment at block number
                 // Make sure valid parameters are selected for next payment at block number
-                ensure!(policy.next_payment_at_block > <system::Module<T>>::block_number(), MSG_FILL_CURATOR_OPENING_INVALID_NEXT_PAYMENT_BLOCK);
+                ensure!(policy.next_payment_at_block > <frame_system::Module<T>>::block_number(), MSG_FILL_CURATOR_OPENING_INVALID_NEXT_PAYMENT_BLOCK);
 
 
                 // The verified reward settings to use
                 // The verified reward settings to use
                 Some((mint_id, policy))
                 Some((mint_id, policy))
@@ -1471,7 +1472,7 @@ decl_module! {
             // == MUTATION SAFE ==
             // == MUTATION SAFE ==
             //
             //
 
 
-            let current_block = <system::Module<T>>::block_number();
+            let current_block = <frame_system::Module<T>>::block_number();
 
 
             // For each successful application
             // For each successful application
             // - create and hold on to curator
             // - create and hold on to curator
@@ -1982,7 +1983,7 @@ impl<T: Trait> Module<T> {
             member_id: member,
             member_id: member,
             role_account,
             role_account,
             reward_relationship: None,
             reward_relationship: None,
-            inducted: <system::Module<T>>::block_number(),
+            inducted: <frame_system::Module<T>>::block_number(),
             stage: LeadRoleState::Active,
             stage: LeadRoleState::Active,
         };
         };
 
 
@@ -2011,7 +2012,7 @@ impl<T: Trait> Module<T> {
         //
         //
 
 
         // Update lead stage as exited
         // Update lead stage as exited
-        let current_block = <system::Module<T>>::block_number();
+        let current_block = <frame_system::Module<T>>::block_number();
 
 
         let new_lead = Lead {
         let new_lead = Lead {
             stage: LeadRoleState::Exited(ExitedLeadRole {
             stage: LeadRoleState::Exited(ExitedLeadRole {
@@ -2279,10 +2280,7 @@ impl<T: Trait> Module<T> {
 
 
         // Ensure curator is still active
         // Ensure curator is still active
         ensure!(
         ensure!(
-            match curator.stage {
-                CuratorRoleStage::Active => true,
-                _ => false,
-            },
+            matches!(curator.stage, CuratorRoleStage::Active),
             MSG_CURATOR_IS_NOT_ACTIVE
             MSG_CURATOR_IS_NOT_ACTIVE
         );
         );
 
 
@@ -2495,7 +2493,7 @@ impl<T: Trait> Module<T> {
         // otherwise they can be terminated right away.
         // otherwise they can be terminated right away.
 
 
         // Create exit summary for this termination
         // Create exit summary for this termination
-        let current_block = <system::Module<T>>::block_number();
+        let current_block = <frame_system::Module<T>>::block_number();
 
 
         let curator_exit_summary =
         let curator_exit_summary =
             CuratorExitSummary::new(exit_initiation_origin, &current_block, rationale_text);
             CuratorExitSummary::new(exit_initiation_origin, &current_block, rationale_text);

+ 12 - 8
runtime-modules/content-working-group/src/mock.rs

@@ -4,13 +4,13 @@ pub use crate::*;
 
 
 use frame_support::traits::{OnFinalize, OnInitialize};
 use frame_support::traits::{OnFinalize, OnInitialize};
 use frame_support::{impl_outer_event, impl_outer_origin, parameter_types};
 use frame_support::{impl_outer_event, impl_outer_origin, parameter_types};
+pub use frame_system;
 use sp_core::H256;
 use sp_core::H256;
 use sp_runtime::{
 use sp_runtime::{
     testing::Header,
     testing::Header,
     traits::{BlakeTwo256, IdentityLookup},
     traits::{BlakeTwo256, IdentityLookup},
     Perbill,
     Perbill,
 };
 };
-pub use system;
 
 
 pub use common::currency::GovernanceCurrency;
 pub use common::currency::GovernanceCurrency;
 pub use hiring;
 pub use hiring;
@@ -50,7 +50,7 @@ impl_outer_event! {
         versioned_store<T>,
         versioned_store<T>,
         membership<T>,
         membership<T>,
         balances<T>,
         balances<T>,
-        system<T>,
+        frame_system<T>,
         lib<T>,
         lib<T>,
     }
     }
 }
 }
@@ -63,7 +63,7 @@ pub type RawLibTestEvent = RawEvent<
     CuratorId<Test>,
     CuratorId<Test>,
     CuratorApplicationIdToCuratorIdMap<Test>,
     CuratorApplicationIdToCuratorIdMap<Test>,
     minting::BalanceOf<Test>,
     minting::BalanceOf<Test>,
-    <Test as system::Trait>::AccountId,
+    <Test as frame_system::Trait>::AccountId,
     <Test as minting::Trait>::MintId,
     <Test as minting::Trait>::MintId,
 >;
 >;
 
 
@@ -75,7 +75,7 @@ pub fn get_last_event_or_panic() -> RawLibTestEvent {
     }
     }
 }
 }
 
 
-impl system::Trait for Test {
+impl frame_system::Trait for Test {
     type BaseCallFilter = ();
     type BaseCallFilter = ();
     type Origin = Origin;
     type Origin = Origin;
     type Call = ();
     type Call = ();
@@ -96,16 +96,18 @@ impl system::Trait for Test {
     type MaximumBlockLength = MaximumBlockLength;
     type MaximumBlockLength = MaximumBlockLength;
     type AvailableBlockRatio = AvailableBlockRatio;
     type AvailableBlockRatio = AvailableBlockRatio;
     type Version = ();
     type Version = ();
-    type ModuleToIndex = ();
+    type PalletInfo = ();
     type AccountData = balances::AccountData<u64>;
     type AccountData = balances::AccountData<u64>;
     type OnNewAccount = ();
     type OnNewAccount = ();
     type OnKilledAccount = ();
     type OnKilledAccount = ();
+    type SystemWeightInfo = ();
 }
 }
 
 
 impl pallet_timestamp::Trait for Test {
 impl pallet_timestamp::Trait for Test {
     type Moment = u64;
     type Moment = u64;
     type OnTimestampSet = ();
     type OnTimestampSet = ();
     type MinimumPeriod = MinimumPeriod;
     type MinimumPeriod = MinimumPeriod;
+    type WeightInfo = ();
 }
 }
 
 
 impl balances::Trait for Test {
 impl balances::Trait for Test {
@@ -114,6 +116,8 @@ impl balances::Trait for Test {
     type Event = TestEvent;
     type Event = TestEvent;
     type ExistentialDeposit = ExistentialDeposit;
     type ExistentialDeposit = ExistentialDeposit;
     type AccountStore = System;
     type AccountStore = System;
+    type WeightInfo = ();
+    type MaxLocks = ();
 }
 }
 
 
 impl GovernanceCurrency for Test {
 impl GovernanceCurrency for Test {
@@ -178,7 +182,7 @@ impl Trait for Test {
 }
 }
 
 
 pub struct TestExternalitiesBuilder<T: Trait> {
 pub struct TestExternalitiesBuilder<T: Trait> {
-    system_config: Option<system::GenesisConfig>,
+    system_config: Option<frame_system::GenesisConfig>,
     membership_config: Option<membership::GenesisConfig<T>>,
     membership_config: Option<membership::GenesisConfig<T>>,
     content_wg_config: Option<GenesisConfig<T>>,
     content_wg_config: Option<GenesisConfig<T>>,
 }
 }
@@ -203,7 +207,7 @@ impl<T: Trait> TestExternalitiesBuilder<T> {
         // Add system
         // Add system
         let mut t = self
         let mut t = self
             .system_config
             .system_config
-            .unwrap_or(system::GenesisConfig::default())
+            .unwrap_or(frame_system::GenesisConfig::default())
             .build_storage::<T>()
             .build_storage::<T>()
             .unwrap();
             .unwrap();
 
 
@@ -230,7 +234,7 @@ impl<T: Trait> TestExternalitiesBuilder<T> {
     }
     }
 }
 }
 
 
-pub type System = system::Module<Test>;
+pub type System = frame_system::Module<Test>;
 pub type Balances = balances::Module<Test>;
 pub type Balances = balances::Module<Test>;
 pub type ContentWorkingGroup = Module<Test>;
 pub type ContentWorkingGroup = Module<Test>;
 pub type Minting = minting::Module<Test>;
 pub type Minting = minting::Module<Test>;

+ 19 - 19
runtime-modules/content-working-group/src/tests.rs

@@ -4,9 +4,9 @@ use super::genesis;
 use super::mock::*;
 use super::mock::*;
 
 
 use frame_support::{assert_err, assert_ok, traits::Currency, StorageValue};
 use frame_support::{assert_err, assert_ok, traits::Currency, StorageValue};
+use frame_system::RawOrigin;
 use sp_arithmetic::traits::One;
 use sp_arithmetic::traits::One;
 use sp_std::collections::{btree_map::BTreeMap, btree_set::BTreeSet};
 use sp_std::collections::{btree_map::BTreeMap, btree_set::BTreeSet};
-use system::RawOrigin;
 
 
 use common::constraints::InputValidationLengthConstraint;
 use common::constraints::InputValidationLengthConstraint;
 use hiring;
 use hiring;
@@ -879,7 +879,7 @@ struct UpdateCuratorRoleAccountFixture {
     pub origin: Origin,
     pub origin: Origin,
     pub member_id: <Test as membership::Trait>::MemberId,
     pub member_id: <Test as membership::Trait>::MemberId,
     pub curator_id: CuratorId<Test>,
     pub curator_id: CuratorId<Test>,
-    pub new_role_account: <Test as system::Trait>::AccountId,
+    pub new_role_account: <Test as frame_system::Trait>::AccountId,
 }
 }
 
 
 impl UpdateCuratorRoleAccountFixture {
 impl UpdateCuratorRoleAccountFixture {
@@ -956,7 +956,7 @@ fn update_curator_role_account_success() {
 struct UpdateCuratorRewardAccountFixture {
 struct UpdateCuratorRewardAccountFixture {
     pub origin: Origin,
     pub origin: Origin,
     pub curator_id: CuratorId<Test>,
     pub curator_id: CuratorId<Test>,
-    pub new_reward_account: <Test as system::Trait>::AccountId,
+    pub new_reward_account: <Test as frame_system::Trait>::AccountId,
 }
 }
 
 
 impl UpdateCuratorRewardAccountFixture {
 impl UpdateCuratorRewardAccountFixture {
@@ -1176,7 +1176,7 @@ fn terminate_curator_role_success() {
 struct SetLeadFixture {
 struct SetLeadFixture {
     pub origin: Origin,
     pub origin: Origin,
     pub member_id: <Test as membership::Trait>::MemberId,
     pub member_id: <Test as membership::Trait>::MemberId,
-    pub new_role_account: <Test as system::Trait>::AccountId,
+    pub new_role_account: <Test as frame_system::Trait>::AccountId,
 }
 }
 
 
 impl SetLeadFixture {
 impl SetLeadFixture {
@@ -1386,10 +1386,10 @@ fn account_can_act_as_principal_success() {}
  * Fixtures
  * Fixtures
  */
  */
 
 
-static LEAD_ROOT_AND_CONTROLLER_ACCOUNT: <Test as system::Trait>::AccountId = 1289;
-static LEAD_ROLE_ACCOUNT: <Test as system::Trait>::AccountId = 1289;
+static LEAD_ROOT_AND_CONTROLLER_ACCOUNT: <Test as frame_system::Trait>::AccountId = 1289;
+static LEAD_ROLE_ACCOUNT: <Test as frame_system::Trait>::AccountId = 1289;
 static LEAD_MEMBER_HANDLE: &str = "IamTheLead";
 static LEAD_MEMBER_HANDLE: &str = "IamTheLead";
-static CHANNEL_CREATOR_ROOT_AND_CONTROLLER_ACCOUNT: <Test as system::Trait>::AccountId = 11;
+static CHANNEL_CREATOR_ROOT_AND_CONTROLLER_ACCOUNT: <Test as frame_system::Trait>::AccountId = 11;
 static CHANNEL_CREATOR_HANDLE: &str = "Coolcreator1";
 static CHANNEL_CREATOR_HANDLE: &str = "Coolcreator1";
 static CHANNEL_CREATOR_HANDLE2: &str = "Coolcreator2";
 static CHANNEL_CREATOR_HANDLE2: &str = "Coolcreator2";
 
 
@@ -1404,7 +1404,7 @@ fn make_generic_add_member_params() -> AddMemberAndApplyOnOpeningParams {
 
 
 /// Made into function to avoid having to clone every time we read fields
 /// Made into function to avoid having to clone every time we read fields
 pub fn get_baseline_opening_policy(
 pub fn get_baseline_opening_policy(
-) -> OpeningPolicyCommitment<<Test as system::Trait>::BlockNumber, BalanceOf<Test>> {
+) -> OpeningPolicyCommitment<<Test as frame_system::Trait>::BlockNumber, BalanceOf<Test>> {
     OpeningPolicyCommitment {
     OpeningPolicyCommitment {
         application_rationing_policy: Some(hiring::ApplicationRationingPolicy {
         application_rationing_policy: Some(hiring::ApplicationRationingPolicy {
             max_active_applicants: 5,
             max_active_applicants: 5,
@@ -1456,17 +1456,17 @@ impl FillOpeningApplicantParams {
 
 
 #[derive(Clone)]
 #[derive(Clone)]
 pub struct AddMemberAndApplyOnOpeningParams {
 pub struct AddMemberAndApplyOnOpeningParams {
-    pub curator_applicant_root_and_controller_account: <Test as system::Trait>::AccountId,
+    pub curator_applicant_root_and_controller_account: <Test as frame_system::Trait>::AccountId,
     pub handle: Vec<u8>,
     pub handle: Vec<u8>,
-    pub curator_applicant_role_account: <Test as system::Trait>::AccountId,
+    pub curator_applicant_role_account: <Test as frame_system::Trait>::AccountId,
     pub human_readable_text: Vec<u8>,
     pub human_readable_text: Vec<u8>,
 }
 }
 
 
 impl AddMemberAndApplyOnOpeningParams {
 impl AddMemberAndApplyOnOpeningParams {
     pub fn new(
     pub fn new(
-        curator_applicant_root_and_controller_account: <Test as system::Trait>::AccountId,
+        curator_applicant_root_and_controller_account: <Test as frame_system::Trait>::AccountId,
         handle: Vec<u8>,
         handle: Vec<u8>,
-        curator_applicant_role_account: <Test as system::Trait>::AccountId,
+        curator_applicant_role_account: <Test as frame_system::Trait>::AccountId,
         human_readable_text: Vec<u8>,
         human_readable_text: Vec<u8>,
     ) -> Self {
     ) -> Self {
         Self {
         Self {
@@ -1505,9 +1505,9 @@ struct NewMemberAppliedResult {
 
 
 fn add_member_and_apply_on_opening(
 fn add_member_and_apply_on_opening(
     curator_opening_id: CuratorOpeningId<Test>,
     curator_opening_id: CuratorOpeningId<Test>,
-    curator_applicant_root_and_controller_account: <Test as system::Trait>::AccountId,
+    curator_applicant_root_and_controller_account: <Test as frame_system::Trait>::AccountId,
     handle: Vec<u8>,
     handle: Vec<u8>,
-    curator_applicant_role_account: <Test as system::Trait>::AccountId,
+    curator_applicant_role_account: <Test as frame_system::Trait>::AccountId,
     human_readable_text: Vec<u8>,
     human_readable_text: Vec<u8>,
 ) -> NewMemberAppliedResult {
 ) -> NewMemberAppliedResult {
     // Make membership
     // Make membership
@@ -1925,8 +1925,8 @@ fn setup_lead_and_hire_curator() -> SetupLeadAndHireCuratorResult {
 
 
 struct CreateChannelFixture {
 struct CreateChannelFixture {
     pub channel_creator_member_id: <Test as membership::Trait>::MemberId,
     pub channel_creator_member_id: <Test as membership::Trait>::MemberId,
-    pub controller_account: <Test as system::Trait>::AccountId,
-    pub channel_creator_role_account: <Test as system::Trait>::AccountId,
+    pub controller_account: <Test as frame_system::Trait>::AccountId,
+    pub channel_creator_role_account: <Test as frame_system::Trait>::AccountId,
     pub channel_handle: Vec<u8>,
     pub channel_handle: Vec<u8>,
     pub channel_title: OptionalText,
     pub channel_title: OptionalText,
     pub description: OptionalText,
     pub description: OptionalText,
@@ -1939,7 +1939,7 @@ struct CreateChannelFixture {
 impl CreateChannelFixture {
 impl CreateChannelFixture {
     pub fn make_valid_unpulished_video_channel_for(
     pub fn make_valid_unpulished_video_channel_for(
         channel_creator_member_id: <Test as membership::Trait>::MemberId,
         channel_creator_member_id: <Test as membership::Trait>::MemberId,
-        override_controller_account: Option<<Test as system::Trait>::AccountId>,
+        override_controller_account: Option<<Test as frame_system::Trait>::AccountId>,
     ) -> Self {
     ) -> Self {
         let controller_account = if let Some(account) = override_controller_account {
         let controller_account = if let Some(account) = override_controller_account {
             account
             account
@@ -2090,7 +2090,7 @@ pub fn add_channel_creator_member() -> <Test as membership::Trait>::MemberId {
 }
 }
 
 
 pub fn add_member(
 pub fn add_member(
-    root_and_controller_account: <Test as system::Trait>::AccountId,
+    root_and_controller_account: <Test as frame_system::Trait>::AccountId,
     handle: Vec<u8>,
     handle: Vec<u8>,
 ) -> <Test as membership::Trait>::MemberId {
 ) -> <Test as membership::Trait>::MemberId {
     let next_member_id = membership::NextMemberId::<Test>::get();
     let next_member_id = membership::NextMemberId::<Test>::get();
@@ -2112,7 +2112,7 @@ pub fn add_member(
 
 
 pub fn set_lead(
 pub fn set_lead(
     member_id: <Test as membership::Trait>::MemberId,
     member_id: <Test as membership::Trait>::MemberId,
-    new_role_account: <Test as system::Trait>::AccountId,
+    new_role_account: <Test as frame_system::Trait>::AccountId,
 ) -> LeadId<Test> {
 ) -> LeadId<Test> {
     /*
     /*
        Events are not emitted on block 0.
        Events are not emitted on block 0.

+ 10 - 10
runtime-modules/forum/Cargo.toml

@@ -6,18 +6,18 @@ edition = '2018'
 
 
 [dependencies]
 [dependencies]
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
-codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
-frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+codec = { package = 'parity-scale-codec', version = '1.3.4', default-features = false, features = ['derive'] }
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 common = { package = 'pallet-common', default-features = false, path = '../common'}
 common = { package = 'pallet-common', default-features = false, path = '../common'}
-sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 
 
 [dev-dependencies]
 [dev-dependencies]
-sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 
 
 [features]
 [features]
 default = ['std']
 default = ['std']
@@ -25,7 +25,7 @@ std = [
 	'serde',
 	'serde',
 	'codec/std',
 	'codec/std',
 	'frame-support/std',
 	'frame-support/std',
-	'system/std',
+	'frame-system/std',
 	'sp-std/std',
 	'sp-std/std',
 	'sp-arithmetic/std',
 	'sp-arithmetic/std',
 	'sp-runtime/std',
 	'sp-runtime/std',

+ 6 - 6
runtime-modules/forum/misc/Cargo.lock

@@ -1541,7 +1541,7 @@ dependencies = [
  "sr-primitives",
  "sr-primitives",
  "sr-std",
  "sr-std",
  "srml-support",
  "srml-support",
- "srml-system",
+ "srml-frame_system",
  "substrate-keyring",
  "substrate-keyring",
 ]
 ]
 
 
@@ -1612,7 +1612,7 @@ dependencies = [
 ]
 ]
 
 
 [[package]]
 [[package]]
-name = "srml-system"
+name = "srml-frame_system"
 version = "2.0.0"
 version = "2.0.0"
 source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3"
 source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3"
 dependencies = [
 dependencies = [
@@ -1639,7 +1639,7 @@ dependencies = [
  "sr-primitives",
  "sr-primitives",
  "sr-std",
  "sr-std",
  "srml-support",
  "srml-support",
- "srml-system",
+ "srml-frame_system",
  "substrate-inherents",
  "substrate-inherents",
 ]
 ]
 
 
@@ -1733,7 +1733,7 @@ dependencies = [
  "srml-balances",
  "srml-balances",
  "srml-support",
  "srml-support",
  "srml-support-procedural",
  "srml-support-procedural",
- "srml-system",
+ "srml-frame_system",
  "srml-timestamp",
  "srml-timestamp",
  "substrate-forum-module 1.1.0",
  "substrate-forum-module 1.1.0",
  "substrate-forum-module 1.1.0 (git+https://github.com/juniuszhou/substrate-forum-module?rev=2c664a211c129fa96b3b4923f73cf850d8177006)",
  "substrate-forum-module 1.1.0 (git+https://github.com/juniuszhou/substrate-forum-module?rev=2c664a211c129fa96b3b4923f73cf850d8177006)",
@@ -1755,7 +1755,7 @@ dependencies = [
  "srml-balances",
  "srml-balances",
  "srml-support",
  "srml-support",
  "srml-support-procedural",
  "srml-support-procedural",
- "srml-system",
+ "srml-frame_system",
  "srml-timestamp",
  "srml-timestamp",
 ]
 ]
 
 
@@ -1773,7 +1773,7 @@ dependencies = [
  "srml-balances",
  "srml-balances",
  "srml-support",
  "srml-support",
  "srml-support-procedural",
  "srml-support-procedural",
- "srml-system",
+ "srml-frame_system",
  "srml-timestamp",
  "srml-timestamp",
  "substrate-forum-module 1.1.0 (git+https://github.com/juniuszhou/substrate-forum-module?rev=2c664a211c129fa96b3b4923f73cf850d8177006)",
  "substrate-forum-module 1.1.0 (git+https://github.com/juniuszhou/substrate-forum-module?rev=2c664a211c129fa96b3b4923f73cf850d8177006)",
  "substrate-primitives",
  "substrate-primitives",

+ 2 - 2
runtime-modules/forum/misc/data-migration/Cargo.toml

@@ -12,7 +12,7 @@ rstd = { package = 'sr-std', default-features = false, git = 'https://github.com
 runtime-primitives = { package = 'sr-primitives', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3'}
 runtime-primitives = { package = 'sr-primitives', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3'}
 srml-support = { package = 'srml-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3'}
 srml-support = { package = 'srml-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3'}
 srml-support-procedural = { package = 'srml-support-procedural', git = 'https://github.com/paritytech/substrate.git', rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3'}
 srml-support-procedural = { package = 'srml-support-procedural', git = 'https://github.com/paritytech/substrate.git', rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3'}
-system = { package = 'srml-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3'}
+frame_system = { package = 'srml-frame_system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3'}
 balances = { package = 'srml-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3'}
 balances = { package = 'srml-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3'}
 codec = { package = 'parity-scale-codec', version = '1.0.0', default-features = false, features = ['derive'] }
 codec = { package = 'parity-scale-codec', version = '1.0.0', default-features = false, features = ['derive'] }
 
 
@@ -54,7 +54,7 @@ std = [
 	'runtime-io/std',
 	'runtime-io/std',
 	'runtime-primitives/std',
 	'runtime-primitives/std',
 	'srml-support/std',
 	'srml-support/std',
-	'system/std',
+	'frame_system/std',
   	'balances/std',
   	'balances/std',
 	'timestamp/std',
 	'timestamp/std',
 	'old-forum/std',
 	'old-forum/std',

+ 9 - 9
runtime-modules/forum/misc/data-migration/benches/data-migration.rs

@@ -29,7 +29,7 @@ mod migration_mod {
 }
 }
 
 
 // forum *lead* was called *sudo* in old version of forum
 // forum *lead* was called *sudo* in old version of forum
-pub const FORUM_LEAD: <Runtime as system::Trait>::AccountId = 33;
+pub const FORUM_LEAD: <Runtime as frame_system::Trait>::AccountId = 33;
 
 
 impl_outer_event! {
 impl_outer_event! {
     pub enum TestEvent for Runtime {
     pub enum TestEvent for Runtime {
@@ -51,7 +51,7 @@ parameter_types! {
     pub const DefaultMigrationConfig: migration::MigrationConfig = Default::default();
     pub const DefaultMigrationConfig: migration::MigrationConfig = Default::default();
 }
 }
 
 
-impl system::Trait for Runtime {
+impl frame_system::Trait for Runtime {
     type Origin = Origin;
     type Origin = Origin;
     type Index = u64;
     type Index = u64;
     type BlockNumber = u64;
     type BlockNumber = u64;
@@ -78,12 +78,12 @@ impl timestamp::Trait for Runtime {
 
 
 pub struct ShimMembershipRegistry {}
 pub struct ShimMembershipRegistry {}
 
 
-impl old_forum::ForumUserRegistry<<Runtime as system::Trait>::AccountId>
+impl old_forum::ForumUserRegistry<<Runtime as frame_system::Trait>::AccountId>
     for ShimMembershipRegistry
     for ShimMembershipRegistry
 {
 {
     fn get_forum_user(
     fn get_forum_user(
-        _id: &<Runtime as system::Trait>::AccountId,
-    ) -> Option<old_forum::ForumUser<<Runtime as system::Trait>::AccountId>> {
+        _id: &<Runtime as frame_system::Trait>::AccountId,
+    ) -> Option<old_forum::ForumUser<<Runtime as frame_system::Trait>::AccountId>> {
         None
         None
     }
     }
 }
 }
@@ -127,7 +127,7 @@ pub fn set_migration_config_mock(
 }
 }
 
 
 pub fn create_migration_data_mock(
 pub fn create_migration_data_mock(
-    account_id: <Runtime as system::Trait>::AccountId,
+    account_id: <Runtime as frame_system::Trait>::AccountId,
     thread_number: u32,
     thread_number: u32,
     post_number: u32,
     post_number: u32,
     text: Vec<u8>,
     text: Vec<u8>,
@@ -135,7 +135,7 @@ pub fn create_migration_data_mock(
     TestModule::create_migration_data(account_id, thread_number, post_number, text);
     TestModule::create_migration_data(account_id, thread_number, post_number, text);
 }
 }
 
 
-pub fn on_initialize_mock(n: <Runtime as system::Trait>::BlockNumber) {
+pub fn on_initialize_mock(n: <Runtime as frame_system::Trait>::BlockNumber) {
     TestModule::on_initialize(n);
     TestModule::on_initialize(n);
 }
 }
 
 
@@ -143,13 +143,13 @@ pub fn on_initialize_mock(n: <Runtime as system::Trait>::BlockNumber) {
 // Wanted to have payload: a: &GenesisConfig<Test>
 // Wanted to have payload: a: &GenesisConfig<Test>
 // but borrow checker made my life miserabl, so giving up for now.
 // but borrow checker made my life miserabl, so giving up for now.
 pub fn build_test_externalities() -> runtime_io::TestExternalities {
 pub fn build_test_externalities() -> runtime_io::TestExternalities {
-    let t = system::GenesisConfig::default()
+    let t = frame_system::GenesisConfig::default()
         .build_storage::<Runtime>()
         .build_storage::<Runtime>()
         .unwrap();
         .unwrap();
     t.into()
     t.into()
 }
 }
 
 
-// pub type System = system::Module<Runtime>;
+// pub type frame_system = frame_system::Module<Runtime>;
 
 
 /// Export forum module on a test runtime
 /// Export forum module on a test runtime
 pub type TestModule = Module<Runtime>;
 pub type TestModule = Module<Runtime>;

+ 3 - 3
runtime-modules/forum/misc/data-migration/src/lib.rs

@@ -46,9 +46,9 @@ impl Default for MigrationConfig {
 }
 }
 
 
 pub trait Trait:
 pub trait Trait:
-    system::Trait + old_forum::Trait + new_forum::Trait + timestamp::Trait + Sized
+    frame_system::Trait + old_forum::Trait + new_forum::Trait + timestamp::Trait + Sized
 {
 {
-    type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
+    type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
     /// Initial balance of members created at genesis
     /// Initial balance of members created at genesis
     type MigrationConfig: Get<MigrationConfig>;
     type MigrationConfig: Get<MigrationConfig>;
 }
 }
@@ -56,7 +56,7 @@ pub trait Trait:
 decl_event!(
 decl_event!(
     pub enum Event<T>
     pub enum Event<T>
     where
     where
-        <T as system::Trait>::BlockNumber,
+        <T as frame_system::Trait>::BlockNumber,
     {
     {
         /// Data migration is done
         /// Data migration is done
         DataMigrationDone(BlockNumber),
         DataMigrationDone(BlockNumber),

+ 10 - 10
runtime-modules/forum/misc/data-migration/src/mock.rs

@@ -27,7 +27,7 @@ mod migration_mod {
     pub use crate::Event;
     pub use crate::Event;
 }
 }
 
 
-pub const FORUM_LEAD: <Runtime as system::Trait>::AccountId = 33;
+pub const FORUM_LEAD: <Runtime as frame_system::Trait>::AccountId = 33;
 
 
 impl_outer_event! {
 impl_outer_event! {
     pub enum TestEvent for Runtime {
     pub enum TestEvent for Runtime {
@@ -49,7 +49,7 @@ parameter_types! {
     pub const DefaultMigrationConfig: MigrationConfig = Default::default();
     pub const DefaultMigrationConfig: MigrationConfig = Default::default();
 }
 }
 
 
-impl system::Trait for Runtime {
+impl frame_system::Trait for Runtime {
     type Origin = Origin;
     type Origin = Origin;
     type Index = u64;
     type Index = u64;
     type BlockNumber = u64;
     type BlockNumber = u64;
@@ -76,12 +76,12 @@ impl timestamp::Trait for Runtime {
 
 
 pub struct ShimMembershipRegistry {}
 pub struct ShimMembershipRegistry {}
 
 
-impl old_forum::ForumUserRegistry<<Runtime as system::Trait>::AccountId>
+impl old_forum::ForumUserRegistry<<Runtime as frame_system::Trait>::AccountId>
     for ShimMembershipRegistry
     for ShimMembershipRegistry
 {
 {
     fn get_forum_user(
     fn get_forum_user(
-        _id: &<Runtime as system::Trait>::AccountId,
-    ) -> Option<old_forum::ForumUser<<Runtime as system::Trait>::AccountId>> {
+        _id: &<Runtime as frame_system::Trait>::AccountId,
+    ) -> Option<old_forum::ForumUser<<Runtime as frame_system::Trait>::AccountId>> {
         None
         None
     }
     }
 }
 }
@@ -121,7 +121,7 @@ pub fn set_migration_config_mock(
 }
 }
 
 
 pub fn create_migration_data_mock(
 pub fn create_migration_data_mock(
-    account_id: <Runtime as system::Trait>::AccountId,
+    account_id: <Runtime as frame_system::Trait>::AccountId,
     thread_number: u32,
     thread_number: u32,
     post_number: u32,
     post_number: u32,
     text: Vec<u8>,
     text: Vec<u8>,
@@ -129,12 +129,12 @@ pub fn create_migration_data_mock(
     TestModule::create_migration_data(account_id, thread_number, post_number, text);
     TestModule::create_migration_data(account_id, thread_number, post_number, text);
 }
 }
 
 
-pub fn on_initialize_mock(n: <Runtime as system::Trait>::BlockNumber, data_migration_done: bool) {
+pub fn on_initialize_mock(n: <Runtime as frame_system::Trait>::BlockNumber, data_migration_done: bool) {
     TestModule::on_initialize(n);
     TestModule::on_initialize(n);
     if data_migration_done {
     if data_migration_done {
         // TODO can't pass compilation
         // TODO can't pass compilation
         // assert_eq!(
         // assert_eq!(
-        //     System::events().last().unwrap().event,
+        //     frame_system::events().last().unwrap().event,
         //     TestEvent::migration_mod(RawEvent::DataMigrationDone(n)),
         //     TestEvent::migration_mod(RawEvent::DataMigrationDone(n)),
         // );
         // );
     };
     };
@@ -144,13 +144,13 @@ pub fn on_initialize_mock(n: <Runtime as system::Trait>::BlockNumber, data_migra
 // Wanted to have payload: a: &GenesisConfig<Test>
 // Wanted to have payload: a: &GenesisConfig<Test>
 // but borrow checker made my life miserabl, so giving up for now.
 // but borrow checker made my life miserabl, so giving up for now.
 pub fn build_test_externalities() -> runtime_io::TestExternalities {
 pub fn build_test_externalities() -> runtime_io::TestExternalities {
-    let t = system::GenesisConfig::default()
+    let t = frame_system::GenesisConfig::default()
         .build_storage::<Runtime>()
         .build_storage::<Runtime>()
         .unwrap();
         .unwrap();
     t.into()
     t.into()
 }
 }
 
 
-// pub type System = system::Module<Runtime>;
+// pub type frame_system = frame_system::Module<Runtime>;
 
 
 /// Export forum module on a test runtime
 /// Export forum module on a test runtime
 pub type TestModule = Module<Runtime>;
 pub type TestModule = Module<Runtime>;

+ 6 - 6
runtime-modules/forum/misc/forum-module/Cargo.lock

@@ -1272,7 +1272,7 @@ dependencies = [
  "sr-primitives",
  "sr-primitives",
  "sr-std",
  "sr-std",
  "srml-support",
  "srml-support",
- "srml-system",
+ "srml-frame_system",
  "substrate-keyring",
  "substrate-keyring",
 ]
 ]
 
 
@@ -1343,7 +1343,7 @@ dependencies = [
 ]
 ]
 
 
 [[package]]
 [[package]]
-name = "srml-system"
+name = "srml-frame_system"
 version = "2.0.0"
 version = "2.0.0"
 source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3"
 source = "git+https://github.com/paritytech/substrate.git?rev=0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3#0e3001a1ad6fa3d1ba7da7342a8d0d3b3facb2f3"
 dependencies = [
 dependencies = [
@@ -1370,7 +1370,7 @@ dependencies = [
  "sr-primitives",
  "sr-primitives",
  "sr-std",
  "sr-std",
  "srml-support",
  "srml-support",
- "srml-system",
+ "srml-frame_system",
  "substrate-inherents",
  "substrate-inherents",
 ]
 ]
 
 
@@ -1463,7 +1463,7 @@ dependencies = [
  "srml-balances",
  "srml-balances",
  "srml-support",
  "srml-support",
  "srml-support-procedural",
  "srml-support-procedural",
- "srml-system",
+ "srml-frame_system",
  "srml-timestamp",
  "srml-timestamp",
  "substrate-forum-module 1.1.0",
  "substrate-forum-module 1.1.0",
  "substrate-forum-module 1.1.0 (git+https://github.com/juniuszhou/substrate-forum-module?rev=2c664a211c129fa96b3b4923f73cf850d8177006)",
  "substrate-forum-module 1.1.0 (git+https://github.com/juniuszhou/substrate-forum-module?rev=2c664a211c129fa96b3b4923f73cf850d8177006)",
@@ -1485,7 +1485,7 @@ dependencies = [
  "srml-balances",
  "srml-balances",
  "srml-support",
  "srml-support",
  "srml-support-procedural",
  "srml-support-procedural",
- "srml-system",
+ "srml-frame_system",
  "srml-timestamp",
  "srml-timestamp",
 ]
 ]
 
 
@@ -1503,7 +1503,7 @@ dependencies = [
  "srml-balances",
  "srml-balances",
  "srml-support",
  "srml-support",
  "srml-support-procedural",
  "srml-support-procedural",
- "srml-system",
+ "srml-frame_system",
  "srml-timestamp",
  "srml-timestamp",
  "substrate-forum-module 1.1.0 (git+https://github.com/juniuszhou/substrate-forum-module?rev=2c664a211c129fa96b3b4923f73cf850d8177006)",
  "substrate-forum-module 1.1.0 (git+https://github.com/juniuszhou/substrate-forum-module?rev=2c664a211c129fa96b3b4923f73cf850d8177006)",
  "substrate-primitives",
  "substrate-primitives",

+ 7 - 7
runtime-modules/forum/src/lib.rs

@@ -225,8 +225,8 @@ use sp_std::prelude::*;
 mod mock;
 mod mock;
 mod tests;
 mod tests;
 
 
-pub trait Trait: system::Trait + pallet_timestamp::Trait + Sized {
-    type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
+pub trait Trait: frame_system::Trait + pallet_timestamp::Trait + Sized {
+    type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
     type ForumUserId: Parameter
     type ForumUserId: Parameter
         + Member
         + Member
         + BaseArithmetic
         + BaseArithmetic
@@ -292,9 +292,9 @@ pub trait Trait: system::Trait + pallet_timestamp::Trait + Sized {
     type MaxCategoryDepth: Get<u64>;
     type MaxCategoryDepth: Get<u64>;
     type MapLimits: StorageLimits;
     type MapLimits: StorageLimits;
 
 
-    fn is_lead(account_id: &<Self as system::Trait>::AccountId) -> bool;
+    fn is_lead(account_id: &<Self as frame_system::Trait>::AccountId) -> bool;
     fn is_forum_member(
     fn is_forum_member(
-        account_id: &<Self as system::Trait>::AccountId,
+        account_id: &<Self as frame_system::Trait>::AccountId,
         forum_user_id: &Self::ForumUserId,
         forum_user_id: &Self::ForumUserId,
     ) -> bool;
     ) -> bool;
     fn is_moderator(account_id: &Self::AccountId, moderator_id: &Self::ModeratorId) -> bool;
     fn is_moderator(account_id: &Self::AccountId, moderator_id: &Self::ModeratorId) -> bool;
@@ -370,7 +370,7 @@ impl InputValidationLengthConstraint {
 //#[cfg(any(feature = "std", test))]
 //#[cfg(any(feature = "std", test))]
 //use sr_primitives::{StorageOverlay, ChildrenStorageOverlay};
 //use sr_primitives::{StorageOverlay, ChildrenStorageOverlay};
 
 
-use system::ensure_signed;
+use frame_system::ensure_signed;
 
 
 /// Represents all poll alternatives and vote count for each one
 /// Represents all poll alternatives and vote count for each one
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
@@ -1156,7 +1156,7 @@ decl_module! {
 }
 }
 
 
 impl<T: Trait> Module<T> {
 impl<T: Trait> Module<T> {
-    // TODO need a safer approach for system call
+    // TODO need a safer approach for frame_system call
     // Interface to add a new thread.
     // Interface to add a new thread.
     // It can be call from other module and this module.
     // It can be call from other module and this module.
     // Method not check the forum user. The extrinsic call it should check if forum id is valid.
     // Method not check the forum user. The extrinsic call it should check if forum id is valid.
@@ -1225,7 +1225,7 @@ impl<T: Trait> Module<T> {
         Ok((new_thread_id, new_thread))
         Ok((new_thread_id, new_thread))
     }
     }
 
 
-    // TODO need a safer approach for system call
+    // TODO need a safer approach for frame_system call
     // Interface to add a new post.
     // Interface to add a new post.
     // It can be call from other module and this module.
     // It can be call from other module and this module.
     // Method not check the forum user. The extrinsic call it should check if forum id is valid.
     // Method not check the forum user. The extrinsic call it should check if forum id is valid.

+ 36 - 36
runtime-modules/forum/src/mock.rs

@@ -26,7 +26,7 @@ mod forum_mod {
 impl_outer_event! {
 impl_outer_event! {
     pub enum TestEvent for Runtime {
     pub enum TestEvent for Runtime {
         forum_mod<T>,
         forum_mod<T>,
-        system<T>,
+        frame_system<T>,
     }
     }
 }
 }
 
 
@@ -41,7 +41,7 @@ parameter_types! {
     pub const MinimumPeriod: u64 = 5;
     pub const MinimumPeriod: u64 = 5;
 }
 }
 
 
-impl system::Trait for Runtime {
+impl frame_system::Trait for Runtime {
     type BaseCallFilter = ();
     type BaseCallFilter = ();
     type Origin = Origin;
     type Origin = Origin;
     type Call = ();
     type Call = ();
@@ -106,12 +106,12 @@ impl Trait for Runtime {
 
 
     type MapLimits = MapLimits;
     type MapLimits = MapLimits;
 
 
-    fn is_lead(account_id: &<Self as system::Trait>::AccountId) -> bool {
+    fn is_lead(account_id: &<Self as frame_system::Trait>::AccountId) -> bool {
         *account_id == FORUM_LEAD_ORIGIN_ID
         *account_id == FORUM_LEAD_ORIGIN_ID
     }
     }
 
 
     fn is_forum_member(
     fn is_forum_member(
-        account_id: &<Self as system::Trait>::AccountId,
+        account_id: &<Self as frame_system::Trait>::AccountId,
         forum_user_id: &Self::ForumUserId,
         forum_user_id: &Self::ForumUserId,
     ) -> bool {
     ) -> bool {
         let allowed_accounts = [
         let allowed_accounts = [
@@ -140,7 +140,7 @@ impl Trait for Runtime {
 
 
 #[derive(Clone)]
 #[derive(Clone)]
 pub enum OriginType {
 pub enum OriginType {
-    Signed(<Runtime as system::Trait>::AccountId),
+    Signed(<Runtime as frame_system::Trait>::AccountId),
     //Inherent, <== did not find how to make such an origin yet
     //Inherent, <== did not find how to make such an origin yet
 }
 }
 
 
@@ -151,25 +151,25 @@ pub fn mock_origin(origin: OriginType) -> mock::Origin {
     }
     }
 }
 }
 
 
-pub const FORUM_LEAD_ORIGIN_ID: <Runtime as system::Trait>::AccountId = 110;
+pub const FORUM_LEAD_ORIGIN_ID: <Runtime as frame_system::Trait>::AccountId = 110;
 
 
 pub const FORUM_LEAD_ORIGIN: OriginType = OriginType::Signed(FORUM_LEAD_ORIGIN_ID);
 pub const FORUM_LEAD_ORIGIN: OriginType = OriginType::Signed(FORUM_LEAD_ORIGIN_ID);
 
 
-pub const NOT_FORUM_LEAD_ORIGIN_ID: <Runtime as system::Trait>::AccountId = 111;
+pub const NOT_FORUM_LEAD_ORIGIN_ID: <Runtime as frame_system::Trait>::AccountId = 111;
 
 
 pub const NOT_FORUM_LEAD_ORIGIN: OriginType = OriginType::Signed(NOT_FORUM_LEAD_ORIGIN_ID);
 pub const NOT_FORUM_LEAD_ORIGIN: OriginType = OriginType::Signed(NOT_FORUM_LEAD_ORIGIN_ID);
 
 
-pub const NOT_FORUM_LEAD_2_ORIGIN_ID: <Runtime as system::Trait>::AccountId = 112;
+pub const NOT_FORUM_LEAD_2_ORIGIN_ID: <Runtime as frame_system::Trait>::AccountId = 112;
 
 
 pub const NOT_FORUM_LEAD_2_ORIGIN: OriginType = OriginType::Signed(NOT_FORUM_LEAD_2_ORIGIN_ID);
 pub const NOT_FORUM_LEAD_2_ORIGIN: OriginType = OriginType::Signed(NOT_FORUM_LEAD_2_ORIGIN_ID);
 
 
 pub const INVLAID_CATEGORY_ID: <Runtime as Trait>::CategoryId = 333;
 pub const INVLAID_CATEGORY_ID: <Runtime as Trait>::CategoryId = 333;
 
 
-pub const FORUM_MODERATOR_ORIGIN_ID: <Runtime as system::Trait>::AccountId = 123;
+pub const FORUM_MODERATOR_ORIGIN_ID: <Runtime as frame_system::Trait>::AccountId = 123;
 
 
 pub const FORUM_MODERATOR_ORIGIN: OriginType = OriginType::Signed(FORUM_MODERATOR_ORIGIN_ID);
 pub const FORUM_MODERATOR_ORIGIN: OriginType = OriginType::Signed(FORUM_MODERATOR_ORIGIN_ID);
 
 
-pub const FORUM_MODERATOR_2_ORIGIN_ID: <Runtime as system::Trait>::AccountId = 124;
+pub const FORUM_MODERATOR_2_ORIGIN_ID: <Runtime as frame_system::Trait>::AccountId = 124;
 
 
 pub const FORUM_MODERATOR_2_ORIGIN: OriginType = OriginType::Signed(FORUM_MODERATOR_2_ORIGIN_ID);
 pub const FORUM_MODERATOR_2_ORIGIN: OriginType = OriginType::Signed(FORUM_MODERATOR_2_ORIGIN_ID);
 
 
@@ -218,7 +218,7 @@ pub fn good_poll_alternative_text() -> Vec<u8> {
 
 
 pub fn generate_poll(
 pub fn generate_poll(
     expiration_diff: u64,
     expiration_diff: u64,
-) -> Poll<<Runtime as pallet_timestamp::Trait>::Moment, <Runtime as system::Trait>::Hash> {
+) -> Poll<<Runtime as pallet_timestamp::Trait>::Moment, <Runtime as frame_system::Trait>::Hash> {
     Poll {
     Poll {
         description_hash: Runtime::calculate_hash(good_poll_description().as_slice()),
         description_hash: Runtime::calculate_hash(good_poll_description().as_slice()),
         end_time: Timestamp::now() + expiration_diff,
         end_time: Timestamp::now() + expiration_diff,
@@ -240,7 +240,7 @@ pub fn generate_poll(
 pub fn generate_poll_timestamp_cases(
 pub fn generate_poll_timestamp_cases(
     index: usize,
     index: usize,
     expiration_diff: u64,
     expiration_diff: u64,
-) -> Poll<<Runtime as pallet_timestamp::Trait>::Moment, <Runtime as system::Trait>::Hash> {
+) -> Poll<<Runtime as pallet_timestamp::Trait>::Moment, <Runtime as frame_system::Trait>::Hash> {
     let test_cases = vec![generate_poll(expiration_diff), generate_poll(1)];
     let test_cases = vec![generate_poll(expiration_diff), generate_poll(1)];
     test_cases[index].clone()
     test_cases[index].clone()
 }
 }
@@ -265,7 +265,7 @@ pub fn create_category_mock(
     if result.is_ok() {
     if result.is_ok() {
         assert_eq!(TestForumModule::next_category_id(), category_id + 1);
         assert_eq!(TestForumModule::next_category_id(), category_id + 1);
         assert_eq!(
         assert_eq!(
-            System::events().last().unwrap().event,
+            frame_system::events().last().unwrap().event,
             TestEvent::forum_mod(RawEvent::CategoryCreated(category_id))
             TestEvent::forum_mod(RawEvent::CategoryCreated(category_id))
         );
         );
     }
     }
@@ -279,7 +279,7 @@ pub fn create_thread_mock(
     title: Vec<u8>,
     title: Vec<u8>,
     text: Vec<u8>,
     text: Vec<u8>,
     poll_data: Option<
     poll_data: Option<
-        Poll<<Runtime as pallet_timestamp::Trait>::Moment, <Runtime as system::Trait>::Hash>,
+        Poll<<Runtime as pallet_timestamp::Trait>::Moment, <Runtime as frame_system::Trait>::Hash>,
     >,
     >,
     result: DispatchResult,
     result: DispatchResult,
 ) -> <Runtime as Trait>::ThreadId {
 ) -> <Runtime as Trait>::ThreadId {
@@ -298,7 +298,7 @@ pub fn create_thread_mock(
     if result.is_ok() {
     if result.is_ok() {
         assert_eq!(TestForumModule::next_thread_id(), thread_id + 1);
         assert_eq!(TestForumModule::next_thread_id(), thread_id + 1);
         assert_eq!(
         assert_eq!(
-            System::events().last().unwrap().event,
+            frame_system::events().last().unwrap().event,
             TestEvent::forum_mod(RawEvent::ThreadCreated(thread_id))
             TestEvent::forum_mod(RawEvent::ThreadCreated(thread_id))
         );
         );
     }
     }
@@ -329,7 +329,7 @@ pub fn edit_thread_title_mock(
             Runtime::calculate_hash(new_title.as_slice()),
             Runtime::calculate_hash(new_title.as_slice()),
         );
         );
         assert_eq!(
         assert_eq!(
-            System::events().last().unwrap().event,
+            frame_system::events().last().unwrap().event,
             TestEvent::forum_mod(RawEvent::ThreadTitleUpdated(thread_id,))
             TestEvent::forum_mod(RawEvent::ThreadTitleUpdated(thread_id,))
         );
         );
     }
     }
@@ -363,7 +363,7 @@ pub fn delete_thread_mock(
             num_direct_threads - 1,
             num_direct_threads - 1,
         );
         );
         assert_eq!(
         assert_eq!(
-            System::events().last().unwrap().event,
+            frame_system::events().last().unwrap().event,
             TestEvent::forum_mod(RawEvent::ThreadDeleted(thread_id))
             TestEvent::forum_mod(RawEvent::ThreadDeleted(thread_id))
         );
         );
     }
     }
@@ -393,7 +393,7 @@ pub fn move_thread_mock(
             thread_id
             thread_id
         ),);
         ),);
         assert_eq!(
         assert_eq!(
-            System::events().last().unwrap().event,
+            frame_system::events().last().unwrap().event,
             TestEvent::forum_mod(RawEvent::ThreadMoved(thread_id, new_category_id))
             TestEvent::forum_mod(RawEvent::ThreadMoved(thread_id, new_category_id))
         );
         );
     }
     }
@@ -419,7 +419,7 @@ pub fn update_thread_archival_status_mock(
     );
     );
     if result.is_ok() {
     if result.is_ok() {
         assert_eq!(
         assert_eq!(
-            System::events().last().unwrap().event,
+            frame_system::events().last().unwrap().event,
             TestEvent::forum_mod(RawEvent::ThreadUpdated(thread_id, new_archival_status))
             TestEvent::forum_mod(RawEvent::ThreadUpdated(thread_id, new_archival_status))
         );
         );
     }
     }
@@ -447,7 +447,7 @@ pub fn create_post_mock(
     if result.is_ok() {
     if result.is_ok() {
         assert_eq!(TestForumModule::next_post_id(), post_id + 1);
         assert_eq!(TestForumModule::next_post_id(), post_id + 1);
         assert_eq!(
         assert_eq!(
-            System::events().last().unwrap().event,
+            frame_system::events().last().unwrap().event,
             TestEvent::forum_mod(RawEvent::PostAdded(post_id))
             TestEvent::forum_mod(RawEvent::PostAdded(post_id))
         );
         );
     };
     };
@@ -480,7 +480,7 @@ pub fn edit_post_text_mock(
             Runtime::calculate_hash(new_text.as_slice()),
             Runtime::calculate_hash(new_text.as_slice()),
         );
         );
         assert_eq!(
         assert_eq!(
-            System::events().last().unwrap().event,
+            frame_system::events().last().unwrap().event,
             TestEvent::forum_mod(RawEvent::PostTextUpdated(post_id))
             TestEvent::forum_mod(RawEvent::PostTextUpdated(post_id))
         );
         );
     }
     }
@@ -545,7 +545,7 @@ pub fn vote_on_poll_mock(
             thread.poll.unwrap().poll_alternatives[index as usize].vote_count + 1
             thread.poll.unwrap().poll_alternatives[index as usize].vote_count + 1
         );
         );
         assert_eq!(
         assert_eq!(
-            System::events().last().unwrap().event,
+            frame_system::events().last().unwrap().event,
             TestEvent::forum_mod(RawEvent::VoteOnPoll(thread_id, index,))
             TestEvent::forum_mod(RawEvent::VoteOnPoll(thread_id, index,))
         );
         );
     };
     };
@@ -570,7 +570,7 @@ pub fn update_category_archival_status_mock(
     );
     );
     if result.is_ok() {
     if result.is_ok() {
         assert_eq!(
         assert_eq!(
-            System::events().last().unwrap().event,
+            frame_system::events().last().unwrap().event,
             TestEvent::forum_mod(RawEvent::CategoryUpdated(category_id, new_archival_status))
             TestEvent::forum_mod(RawEvent::CategoryUpdated(category_id, new_archival_status))
         );
         );
     }
     }
@@ -589,7 +589,7 @@ pub fn delete_category_mock(
     if result.is_ok() {
     if result.is_ok() {
         assert!(!<CategoryById<Runtime>>::contains_key(category_id));
         assert!(!<CategoryById<Runtime>>::contains_key(category_id));
         assert_eq!(
         assert_eq!(
-            System::events().last().unwrap().event,
+            frame_system::events().last().unwrap().event,
             TestEvent::forum_mod(RawEvent::CategoryDeleted(category_id))
             TestEvent::forum_mod(RawEvent::CategoryDeleted(category_id))
         );
         );
     };
     };
@@ -616,7 +616,7 @@ pub fn moderate_thread_mock(
     if result.is_ok() {
     if result.is_ok() {
         assert!(!<ThreadById<Runtime>>::contains_key(category_id, thread_id));
         assert!(!<ThreadById<Runtime>>::contains_key(category_id, thread_id));
         assert_eq!(
         assert_eq!(
-            System::events().last().unwrap().event,
+            frame_system::events().last().unwrap().event,
             TestEvent::forum_mod(RawEvent::ThreadModerated(thread_id, rationale))
             TestEvent::forum_mod(RawEvent::ThreadModerated(thread_id, rationale))
         );
         );
     }
     }
@@ -646,7 +646,7 @@ pub fn moderate_post_mock(
     if result.is_ok() {
     if result.is_ok() {
         assert!(!<PostById<Runtime>>::contains_key(thread_id, post_id));
         assert!(!<PostById<Runtime>>::contains_key(thread_id, post_id));
         assert_eq!(
         assert_eq!(
-            System::events().last().unwrap().event,
+            frame_system::events().last().unwrap().event,
             TestEvent::forum_mod(RawEvent::PostModerated(post_id, rationale))
             TestEvent::forum_mod(RawEvent::PostModerated(post_id, rationale))
         );
         );
     }
     }
@@ -676,7 +676,7 @@ pub fn set_stickied_threads_mock(
             stickied_ids.clone()
             stickied_ids.clone()
         );
         );
         assert_eq!(
         assert_eq!(
-            System::events().last().unwrap().event,
+            frame_system::events().last().unwrap().event,
             TestEvent::forum_mod(RawEvent::CategoryStickyThreadUpdate(
             TestEvent::forum_mod(RawEvent::CategoryStickyThreadUpdate(
                 category_id,
                 category_id,
                 stickied_ids.clone(),
                 stickied_ids.clone(),
@@ -708,7 +708,7 @@ pub fn react_post_mock(
     );
     );
     if result.is_ok() {
     if result.is_ok() {
         assert_eq!(
         assert_eq!(
-            System::events().last().unwrap().event,
+            frame_system::events().last().unwrap().event,
             TestEvent::forum_mod(RawEvent::PostReacted(
             TestEvent::forum_mod(RawEvent::PostReacted(
                 forum_user_id,
                 forum_user_id,
                 post_id,
                 post_id,
@@ -752,7 +752,7 @@ pub fn create_genesis_config(data_migration_done: bool) -> GenesisConfig<Runtime
 // Wanted to have payload: a: &GenesisConfig<Test>
 // Wanted to have payload: a: &GenesisConfig<Test>
 // but borrow checker made my life miserabl, so giving up for now.
 // but borrow checker made my life miserabl, so giving up for now.
 pub fn build_test_externalities(config: GenesisConfig<Runtime>) -> sp_io::TestExternalities {
 pub fn build_test_externalities(config: GenesisConfig<Runtime>) -> sp_io::TestExternalities {
-    let mut t = system::GenesisConfig::default()
+    let mut t = frame_system::GenesisConfig::default()
         .build_storage::<Runtime>()
         .build_storage::<Runtime>()
         .unwrap();
         .unwrap();
 
 
@@ -779,16 +779,16 @@ pub fn with_test_externalities<R, F: FnOnce() -> R>(f: F) -> R {
 // Recommendation from Parity on testing on_finalize
 // Recommendation from Parity on testing on_finalize
 // https://substrate.dev/docs/en/next/development/module/tests
 // https://substrate.dev/docs/en/next/development/module/tests
 pub fn run_to_block(n: u64) {
 pub fn run_to_block(n: u64) {
-    while System::block_number() < n {
-        <System as OnFinalize<u64>>::on_finalize(System::block_number());
-        <TestForumModule as OnFinalize<u64>>::on_finalize(System::block_number());
-        System::set_block_number(System::block_number() + 1);
-        <System as OnInitialize<u64>>::on_initialize(System::block_number());
-        <TestForumModule as OnInitialize<u64>>::on_initialize(System::block_number());
+    while frame_system::block_number() < n {
+        <frame_system as OnFinalize<u64>>::on_finalize(frame_system::block_number());
+        <TestForumModule as OnFinalize<u64>>::on_finalize(frame_system::block_number());
+        frame_system::set_block_number(frame_system::block_number() + 1);
+        <frame_system as OnInitialize<u64>>::on_initialize(frame_system::block_number());
+        <TestForumModule as OnInitialize<u64>>::on_initialize(frame_system::block_number());
     }
     }
 }
 }
 
 
-pub type System = system::Module<Runtime>;
+pub type frame_system = frame_system::Module<Runtime>;
 
 
 pub type Timestamp = pallet_timestamp::Module<Runtime>;
 pub type Timestamp = pallet_timestamp::Module<Runtime>;
 
 

+ 12 - 12
runtime-modules/governance/Cargo.toml

@@ -1,27 +1,27 @@
 [package]
 [package]
 name = 'pallet-governance'
 name = 'pallet-governance'
-version = '3.0.0'
+version = '3.1.0'
 authors = ['Joystream contributors']
 authors = ['Joystream contributors']
 edition = '2018'
 edition = '2018'
 
 
 [dependencies]
 [dependencies]
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
-codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
-sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+codec = { package = 'parity-scale-codec', version = '1.3.4', default-features = false, features = ['derive'] }
+sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 membership = { package = 'pallet-membership', default-features = false, path = '../membership'}
 membership = { package = 'pallet-membership', default-features = false, path = '../membership'}
 minting = { package = 'pallet-token-mint', default-features = false, path = '../token-minting'}
 minting = { package = 'pallet-token-mint', default-features = false, path = '../token-minting'}
 recurringrewards = { package = 'pallet-recurring-reward', default-features = false, path = '../recurring-reward'}
 recurringrewards = { package = 'pallet-recurring-reward', default-features = false, path = '../recurring-reward'}
 common = { package = 'pallet-common', default-features = false, path = '../common'}
 common = { package = 'pallet-common', default-features = false, path = '../common'}
 
 
 [dev-dependencies]
 [dev-dependencies]
-sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 
 
 [features]
 [features]
 default = ['std']
 default = ['std']
@@ -30,7 +30,7 @@ std = [
 	'codec/std',
 	'codec/std',
 	'sp-std/std',
 	'sp-std/std',
 	'frame-support/std',
 	'frame-support/std',
-	'system/std',
+	'frame-system/std',
 	'sp-arithmetic/std',
 	'sp-arithmetic/std',
 	'sp-runtime/std',
 	'sp-runtime/std',
 	'pallet-timestamp/std',
 	'pallet-timestamp/std',

+ 17 - 14
runtime-modules/governance/src/council.rs

@@ -1,8 +1,8 @@
 use frame_support::{debug, decl_event, decl_module, decl_storage, ensure};
 use frame_support::{debug, decl_event, decl_module, decl_storage, ensure};
+use frame_system::ensure_root;
 use sp_arithmetic::traits::{One, Zero};
 use sp_arithmetic::traits::{One, Zero};
 use sp_std::vec;
 use sp_std::vec;
 use sp_std::vec::Vec;
 use sp_std::vec::Vec;
-use system::ensure_root;
 
 
 pub use super::election::{self, CouncilElected, Seat, Seats};
 pub use super::election::{self, CouncilElected, Seat, Seats};
 pub use common::currency::{BalanceOf, GovernanceCurrency};
 pub use common::currency::{BalanceOf, GovernanceCurrency};
@@ -22,8 +22,8 @@ impl<X: CouncilTermEnded> CouncilTermEnded for (X,) {
     }
     }
 }
 }
 
 
-pub trait Trait: system::Trait + recurringrewards::Trait + GovernanceCurrency {
-    type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
+pub trait Trait: frame_system::Trait + recurringrewards::Trait + GovernanceCurrency {
+    type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
 
 
     type CouncilTermEnded: CouncilTermEnded;
     type CouncilTermEnded: CouncilTermEnded;
 }
 }
@@ -71,7 +71,7 @@ decl_storage! {
 
 
 // Event for this module.
 // Event for this module.
 decl_event!(
 decl_event!(
-    pub enum Event<T> where <T as system::Trait>::BlockNumber {
+    pub enum Event<T> where <T as frame_system::Trait>::BlockNumber {
         CouncilTermEnded(BlockNumber),
         CouncilTermEnded(BlockNumber),
         NewCouncilTermStarted(BlockNumber),
         NewCouncilTermStarted(BlockNumber),
     }
     }
@@ -81,7 +81,7 @@ impl<T: Trait> CouncilElected<Seats<T::AccountId, BalanceOf<T>>, T::BlockNumber>
     fn council_elected(seats: Seats<T::AccountId, BalanceOf<T>>, term: T::BlockNumber) {
     fn council_elected(seats: Seats<T::AccountId, BalanceOf<T>>, term: T::BlockNumber) {
         <ActiveCouncil<T>>::put(seats.clone());
         <ActiveCouncil<T>>::put(seats.clone());
 
 
-        let next_term_ends_at = <system::Module<T>>::block_number() + term;
+        let next_term_ends_at = <frame_system::Module<T>>::block_number() + term;
 
 
         <TermEndsAt<T>>::put(next_term_ends_at);
         <TermEndsAt<T>>::put(next_term_ends_at);
 
 
@@ -95,7 +95,7 @@ impl<T: Trait> CouncilElected<Seats<T::AccountId, BalanceOf<T>>, T::BlockNumber>
 
 
 impl<T: Trait> Module<T> {
 impl<T: Trait> Module<T> {
     pub fn is_term_ended() -> bool {
     pub fn is_term_ended() -> bool {
-        <system::Module<T>>::block_number() >= Self::term_ends_at()
+        <frame_system::Module<T>>::block_number() >= Self::term_ends_at()
     }
     }
 
 
     pub fn is_councilor(sender: &T::AccountId) -> bool {
     pub fn is_councilor(sender: &T::AccountId) -> bool {
@@ -107,7 +107,7 @@ impl<T: Trait> Module<T> {
 
 
         // When calculating when first payout occurs, add minimum of one block interval to ensure rewards module
         // When calculating when first payout occurs, add minimum of one block interval to ensure rewards module
         // has a chance to execute its on_finalize routine.
         // has a chance to execute its on_finalize routine.
-        let next_payout_at = system::Module::<T>::block_number()
+        let next_payout_at = frame_system::Module::<T>::block_number()
             + Self::first_payout_after_reward_created()
             + Self::first_payout_after_reward_created()
             + T::BlockNumber::one();
             + T::BlockNumber::one();
 
 
@@ -229,7 +229,7 @@ decl_module! {
         #[weight = 10_000_000] // TODO: adjust weight
         #[weight = 10_000_000] // TODO: adjust weight
         fn set_term_ends_at(origin, ends_at: T::BlockNumber) {
         fn set_term_ends_at(origin, ends_at: T::BlockNumber) {
             ensure_root(origin)?;
             ensure_root(origin)?;
-            ensure!(ends_at > <system::Module<T>>::block_number(), "must set future block number");
+            ensure!(ends_at > <frame_system::Module<T>>::block_number(), "must set future block number");
             <TermEndsAt<T>>::put(ends_at);
             <TermEndsAt<T>>::put(ends_at);
         }
         }
 
 
@@ -280,8 +280,11 @@ mod tests {
     use crate::DispatchResult;
     use crate::DispatchResult;
     use frame_support::*;
     use frame_support::*;
 
 
-    fn add_council_member_as_root(account: <Test as system::Trait>::AccountId) -> DispatchResult {
-        Council::add_council_member(system::RawOrigin::Root.into(), account).map_err(|e| e.into())
+    fn add_council_member_as_root(
+        account: <Test as frame_system::Trait>::AccountId,
+    ) -> DispatchResult {
+        Council::add_council_member(frame_system::RawOrigin::Root.into(), account)
+            .map_err(|e| e.into())
     }
     }
 
 
     #[test]
     #[test]
@@ -306,7 +309,7 @@ mod tests {
             assert_ok!(add_council_member_as_root(3));
             assert_ok!(add_council_member_as_root(3));
 
 
             assert_ok!(Council::remove_council_member(
             assert_ok!(Council::remove_council_member(
-                system::RawOrigin::Root.into(),
+                frame_system::RawOrigin::Root.into(),
                 2
                 2
             ));
             ));
 
 
@@ -320,7 +323,7 @@ mod tests {
     fn set_council_test() {
     fn set_council_test() {
         initial_test_ext().execute_with(|| {
         initial_test_ext().execute_with(|| {
             assert_ok!(Council::set_council(
             assert_ok!(Council::set_council(
-                system::RawOrigin::Root.into(),
+                frame_system::RawOrigin::Root.into(),
                 vec![4, 5, 6]
                 vec![4, 5, 6]
             ));
             ));
             assert!(Council::is_councilor(&4));
             assert!(Council::is_councilor(&4));
@@ -334,7 +337,7 @@ mod tests {
         initial_test_ext().execute_with(|| {
         initial_test_ext().execute_with(|| {
             // Ensure a mint is created so we can create rewards
             // Ensure a mint is created so we can create rewards
             assert_ok!(Council::set_council_mint_capacity(
             assert_ok!(Council::set_council_mint_capacity(
-                system::RawOrigin::Root.into(),
+                frame_system::RawOrigin::Root.into(),
                 1000
                 1000
             ));
             ));
 
 
@@ -356,7 +359,7 @@ mod tests {
                         backers: vec![],
                         backers: vec![],
                     },
                     },
                 ],
                 ],
-                50 as u64, // <Test as system::Trait>::BlockNumber::from(50)
+                50 as u64, // <Test as frame_system::Trait>::BlockNumber::from(50)
             );
             );
 
 
             assert!(Council::is_councilor(&5));
             assert!(Council::is_councilor(&5));

+ 32 - 33
runtime-modules/governance/src/election.rs

@@ -35,13 +35,13 @@ use serde::{Deserialize, Serialize};
 use codec::{Decode, Encode};
 use codec::{Decode, Encode};
 use frame_support::traits::{Currency, ReservableCurrency};
 use frame_support::traits::{Currency, ReservableCurrency};
 use frame_support::{decl_event, decl_module, decl_storage, ensure};
 use frame_support::{decl_event, decl_module, decl_storage, ensure};
+use frame_system::{ensure_root, ensure_signed};
 use sp_arithmetic::traits::Zero;
 use sp_arithmetic::traits::Zero;
 use sp_runtime::traits::Hash;
 use sp_runtime::traits::Hash;
 use sp_std::collections::btree_map::BTreeMap;
 use sp_std::collections::btree_map::BTreeMap;
 use sp_std::ops::Add;
 use sp_std::ops::Add;
 use sp_std::vec;
 use sp_std::vec;
 use sp_std::vec::Vec;
 use sp_std::vec::Vec;
-use system::{ensure_root, ensure_signed};
 
 
 use super::sealed_vote::SealedVote;
 use super::sealed_vote::SealedVote;
 use super::stake::Stake;
 use super::stake::Stake;
@@ -52,8 +52,10 @@ pub use common::currency::{BalanceOf, GovernanceCurrency};
 
 
 use crate::DispatchResult;
 use crate::DispatchResult;
 
 
-pub trait Trait: system::Trait + council::Trait + GovernanceCurrency + membership::Trait {
-    type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
+pub trait Trait:
+    frame_system::Trait + council::Trait + GovernanceCurrency + membership::Trait
+{
+    type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
 
 
     type CouncilElected: CouncilElected<Seats<Self::AccountId, BalanceOf<Self>>, Self::BlockNumber>;
     type CouncilElected: CouncilElected<Seats<Self::AccountId, BalanceOf<Self>>, Self::BlockNumber>;
 }
 }
@@ -183,9 +185,9 @@ decl_storage! {
 // Event for this module.
 // Event for this module.
 decl_event!(
 decl_event!(
     pub enum Event<T> where
     pub enum Event<T> where
-    <T as system::Trait>::BlockNumber,
-    <T as system::Trait>::AccountId,
-    <T as system::Trait>::Hash  {
+    <T as frame_system::Trait>::BlockNumber,
+    <T as frame_system::Trait>::AccountId,
+    <T as frame_system::Trait>::Hash  {
         /// A new election started
         /// A new election started
         ElectionStarted(),
         ElectionStarted(),
         AnnouncingStarted(u32),
         AnnouncingStarted(u32),
@@ -213,7 +215,7 @@ impl<T: Trait> Module<T> {
     }
     }
 
 
     fn current_block_number_plus(length: T::BlockNumber) -> T::BlockNumber {
     fn current_block_number_plus(length: T::BlockNumber) -> T::BlockNumber {
-        <system::Module<T>>::block_number() + length
+        <frame_system::Module<T>>::block_number() + length
     }
     }
 
 
     fn can_participate(sender: &T::AccountId) -> bool {
     fn can_participate(sender: &T::AccountId) -> bool {
@@ -394,7 +396,9 @@ impl<T: Trait> Module<T> {
         let new_council = new_council.into_iter().map(|(_, seat)| seat).collect();
         let new_council = new_council.into_iter().map(|(_, seat)| seat).collect();
         T::CouncilElected::council_elected(new_council, Self::new_term_duration());
         T::CouncilElected::council_elected(new_council, Self::new_term_duration());
 
 
-        Self::deposit_event(RawEvent::CouncilElected(<system::Module<T>>::block_number()));
+        Self::deposit_event(RawEvent::CouncilElected(
+            <frame_system::Module<T>>::block_number(),
+        ));
     }
     }
 
 
     fn teardown_election(
     fn teardown_election(
@@ -785,7 +789,11 @@ impl<T: Trait> Module<T> {
         let mut salt = salt;
         let mut salt = salt;
 
 
         // Tries to unseal, if salt is invalid will return error
         // Tries to unseal, if salt is invalid will return error
-        sealed_vote.unseal(vote_for, &mut salt, <T as system::Trait>::Hashing::hash)?;
+        sealed_vote.unseal(
+            vote_for,
+            &mut salt,
+            <T as frame_system::Trait>::Hashing::hash,
+        )?;
 
 
         // Update the revealed vote
         // Update the revealed vote
         <Votes<T>>::insert(commitment, sealed_vote);
         <Votes<T>>::insert(commitment, sealed_vote);
@@ -824,10 +832,7 @@ decl_module! {
             let stage = Self::stage();
             let stage = Self::stage();
             ensure!(Self::stage().is_some(), "election not running");
             ensure!(Self::stage().is_some(), "election not running");
 
 
-            let is_announcing = match stage.unwrap() {
-                ElectionStage::Announcing(_) => true,
-                _ => false
-            };
+            let is_announcing = matches!(stage.unwrap(), ElectionStage::Announcing(_));
             ensure!(is_announcing, "election not in announcing stage");
             ensure!(is_announcing, "election not in announcing stage");
 
 
             // minimum stake on first attempt to apply
             // minimum stake on first attempt to apply
@@ -848,10 +853,7 @@ decl_module! {
             let stage = Self::stage();
             let stage = Self::stage();
             ensure!(Self::stage().is_some(), "election not running");
             ensure!(Self::stage().is_some(), "election not running");
 
 
-            let is_voting = match stage.unwrap() {
-                ElectionStage::Voting(_) => true,
-                _ => false
-            };
+            let is_voting =  matches!(stage.unwrap(), ElectionStage::Voting(_));
             ensure!(is_voting, "election not in voting stage");
             ensure!(is_voting, "election not in voting stage");
 
 
             ensure!(stake >= Self::min_voting_stake(), "voting stake too low");
             ensure!(stake >= Self::min_voting_stake(), "voting stake too low");
@@ -868,10 +870,7 @@ decl_module! {
             let stage = Self::stage();
             let stage = Self::stage();
             ensure!(Self::stage().is_some(), "election not running");
             ensure!(Self::stage().is_some(), "election not running");
 
 
-            let is_revealing = match stage.unwrap() {
-                ElectionStage::Revealing(_) => true,
-                _ => false
-            };
+            let is_revealing = matches!(stage.unwrap(), ElectionStage::Revealing(_));
             ensure!(is_revealing, "election not in revealing stage");
             ensure!(is_revealing, "election not in revealing stage");
 
 
             Self::try_reveal_vote(sender.clone(), commitment, vote.clone(), salt)?;
             Self::try_reveal_vote(sender.clone(), commitment, vote.clone(), salt)?;
@@ -881,21 +880,21 @@ decl_module! {
         #[weight = 10_000_000] // TODO: adjust weight
         #[weight = 10_000_000] // TODO: adjust weight
         fn set_stage_announcing(origin, ends_at: T::BlockNumber) {
         fn set_stage_announcing(origin, ends_at: T::BlockNumber) {
             ensure_root(origin)?;
             ensure_root(origin)?;
-            ensure!(ends_at > <system::Module<T>>::block_number(), "must end at future block number");
+            ensure!(ends_at > <frame_system::Module<T>>::block_number(), "must end at future block number");
             <Stage<T>>::put(ElectionStage::Announcing(ends_at));
             <Stage<T>>::put(ElectionStage::Announcing(ends_at));
         }
         }
 
 
         #[weight = 10_000_000] // TODO: adjust weight
         #[weight = 10_000_000] // TODO: adjust weight
         fn set_stage_revealing(origin, ends_at: T::BlockNumber) {
         fn set_stage_revealing(origin, ends_at: T::BlockNumber) {
             ensure_root(origin)?;
             ensure_root(origin)?;
-            ensure!(ends_at > <system::Module<T>>::block_number(), "must end at future block number");
+            ensure!(ends_at > <frame_system::Module<T>>::block_number(), "must end at future block number");
             <Stage<T>>::put(ElectionStage::Revealing(ends_at));
             <Stage<T>>::put(ElectionStage::Revealing(ends_at));
         }
         }
 
 
         #[weight = 10_000_000] // TODO: adjust weight
         #[weight = 10_000_000] // TODO: adjust weight
         fn set_stage_voting(origin, ends_at: T::BlockNumber) {
         fn set_stage_voting(origin, ends_at: T::BlockNumber) {
             ensure_root(origin)?;
             ensure_root(origin)?;
-            ensure!(ends_at > <system::Module<T>>::block_number(), "must end at future block number");
+            ensure!(ends_at > <frame_system::Module<T>>::block_number(), "must end at future block number");
             <Stage<T>>::put(ElectionStage::Voting(ends_at));
             <Stage<T>>::put(ElectionStage::Voting(ends_at));
         }
         }
 
 
@@ -961,7 +960,7 @@ mod tests {
     use codec::Encode;
     use codec::Encode;
     use frame_support::traits::OnFinalize;
     use frame_support::traits::OnFinalize;
     use frame_support::{assert_err, assert_ok};
     use frame_support::{assert_err, assert_ok};
-    use system::RawOrigin;
+    use frame_system::RawOrigin;
 
 
     #[test]
     #[test]
     fn election_starts_when_council_term_ends() {
     fn election_starts_when_council_term_ends() {
@@ -1022,7 +1021,7 @@ mod tests {
         });
         });
     }
     }
 
 
-    fn assert_announcing_period(expected_period: <Test as system::Trait>::BlockNumber) {
+    fn assert_announcing_period(expected_period: <Test as frame_system::Trait>::BlockNumber) {
         assert!(
         assert!(
             Election::is_election_running(),
             Election::is_election_running(),
             "Election Stage was not set"
             "Election Stage was not set"
@@ -1388,7 +1387,7 @@ mod tests {
         initial_test_ext().execute_with(|| {
         initial_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&20, 1000);
             let _ = Balances::deposit_creating(&20, 1000);
             let payload = vec![10u8];
             let payload = vec![10u8];
-            let commitment = <Test as system::Trait>::Hashing::hash(&payload[..]);
+            let commitment = <Test as frame_system::Trait>::Hashing::hash(&payload[..]);
 
 
             assert!(Election::try_add_vote(20, 100, commitment).is_ok());
             assert!(Election::try_add_vote(20, 100, commitment).is_ok());
 
 
@@ -1424,7 +1423,7 @@ mod tests {
             );
             );
 
 
             let payload = vec![10u8];
             let payload = vec![10u8];
-            let commitment = <Test as system::Trait>::Hashing::hash(&payload[..]);
+            let commitment = <Test as frame_system::Trait>::Hashing::hash(&payload[..]);
 
 
             assert!(Election::try_add_vote(20, 100, commitment).is_ok());
             assert!(Election::try_add_vote(20, 100, commitment).is_ok());
 
 
@@ -1456,7 +1455,7 @@ mod tests {
             );
             );
 
 
             let payload = vec![10u8];
             let payload = vec![10u8];
-            let commitment = <Test as system::Trait>::Hashing::hash(&payload[..]);
+            let commitment = <Test as frame_system::Trait>::Hashing::hash(&payload[..]);
 
 
             assert!(Election::try_add_vote(20, 1000, commitment).is_err());
             assert!(Election::try_add_vote(20, 1000, commitment).is_err());
             assert_eq!(Election::commitments(), vec![]);
             assert_eq!(Election::commitments(), vec![]);
@@ -1479,7 +1478,7 @@ mod tests {
             );
             );
 
 
             let payload = vec![10u8];
             let payload = vec![10u8];
-            let commitment = <Test as system::Trait>::Hashing::hash(&payload[..]);
+            let commitment = <Test as frame_system::Trait>::Hashing::hash(&payload[..]);
 
 
             assert!(Election::try_add_vote(20, 100, commitment).is_ok());
             assert!(Election::try_add_vote(20, 100, commitment).is_ok());
 
 
@@ -1500,12 +1499,12 @@ mod tests {
     }
     }
 
 
     fn make_commitment_for_applicant(
     fn make_commitment_for_applicant(
-        applicant: <Test as system::Trait>::AccountId,
+        applicant: <Test as frame_system::Trait>::AccountId,
         salt: &mut Vec<u8>,
         salt: &mut Vec<u8>,
-    ) -> <Test as system::Trait>::Hash {
+    ) -> <Test as frame_system::Trait>::Hash {
         let mut payload = applicant.encode();
         let mut payload = applicant.encode();
         payload.append(salt);
         payload.append(salt);
-        <Test as system::Trait>::Hashing::hash(&payload[..])
+        <Test as frame_system::Trait>::Hashing::hash(&payload[..])
     }
     }
 
 
     #[test]
     #[test]

+ 9 - 5
runtime-modules/governance/src/mock.rs

@@ -4,13 +4,13 @@ pub use super::{council, election};
 pub use common::currency::GovernanceCurrency;
 pub use common::currency::GovernanceCurrency;
 
 
 use frame_support::{impl_outer_origin, parameter_types};
 use frame_support::{impl_outer_origin, parameter_types};
+pub use frame_system;
 use sp_core::H256;
 use sp_core::H256;
 use sp_runtime::{
 use sp_runtime::{
     testing::Header,
     testing::Header,
     traits::{BlakeTwo256, IdentityLookup},
     traits::{BlakeTwo256, IdentityLookup},
     BuildStorage, Perbill,
     BuildStorage, Perbill,
 };
 };
-pub use system;
 
 
 impl_outer_origin! {
 impl_outer_origin! {
     pub enum Origin for Test {}
     pub enum Origin for Test {}
@@ -27,7 +27,7 @@ parameter_types! {
     pub const MinimumPeriod: u64 = 5;
     pub const MinimumPeriod: u64 = 5;
 }
 }
 
 
-impl system::Trait for Test {
+impl frame_system::Trait for Test {
     type BaseCallFilter = ();
     type BaseCallFilter = ();
     type Origin = Origin;
     type Origin = Origin;
     type Call = ();
     type Call = ();
@@ -48,16 +48,18 @@ impl system::Trait for Test {
     type MaximumBlockLength = MaximumBlockLength;
     type MaximumBlockLength = MaximumBlockLength;
     type AvailableBlockRatio = AvailableBlockRatio;
     type AvailableBlockRatio = AvailableBlockRatio;
     type Version = ();
     type Version = ();
-    type ModuleToIndex = ();
+    type PalletInfo = ();
     type AccountData = balances::AccountData<u64>;
     type AccountData = balances::AccountData<u64>;
     type OnNewAccount = ();
     type OnNewAccount = ();
     type OnKilledAccount = ();
     type OnKilledAccount = ();
+    type SystemWeightInfo = ();
 }
 }
 
 
 impl pallet_timestamp::Trait for Test {
 impl pallet_timestamp::Trait for Test {
     type Moment = u64;
     type Moment = u64;
     type OnTimestampSet = ();
     type OnTimestampSet = ();
     type MinimumPeriod = MinimumPeriod;
     type MinimumPeriod = MinimumPeriod;
+    type WeightInfo = ();
 }
 }
 impl council::Trait for Test {
 impl council::Trait for Test {
     type Event = ();
     type Event = ();
@@ -95,6 +97,8 @@ impl balances::Trait for Test {
     type Event = ();
     type Event = ();
     type ExistentialDeposit = ExistentialDeposit;
     type ExistentialDeposit = ExistentialDeposit;
     type AccountStore = System;
     type AccountStore = System;
+    type WeightInfo = ();
+    type MaxLocks = ();
 }
 }
 
 
 impl GovernanceCurrency for Test {
 impl GovernanceCurrency for Test {
@@ -106,7 +110,7 @@ impl GovernanceCurrency for Test {
 // This function basically just builds a genesis storage key/value store according to
 // This function basically just builds a genesis storage key/value store according to
 // our desired mockup.
 // our desired mockup.
 pub fn initial_test_ext() -> sp_io::TestExternalities {
 pub fn initial_test_ext() -> sp_io::TestExternalities {
-    let mut t = system::GenesisConfig::default()
+    let mut t = frame_system::GenesisConfig::default()
         .build_storage::<Test>()
         .build_storage::<Test>()
         .unwrap();
         .unwrap();
 
 
@@ -153,5 +157,5 @@ pub fn initial_test_ext() -> sp_io::TestExternalities {
 
 
 pub type Election = election::Module<Test>;
 pub type Election = election::Module<Test>;
 pub type Council = council::Module<Test>;
 pub type Council = council::Module<Test>;
-pub type System = system::Module<Test>;
+pub type System = frame_system::Module<Test>;
 pub type Balances = balances::Module<Test>;
 pub type Balances = balances::Module<Test>;

+ 11 - 11
runtime-modules/hiring/Cargo.toml

@@ -1,24 +1,24 @@
 [package]
 [package]
 name = 'pallet-hiring'
 name = 'pallet-hiring'
-version = '3.0.0'
+version = '3.1.0'
 authors = ['Joystream contributors']
 authors = ['Joystream contributors']
 edition = '2018'
 edition = '2018'
 
 
 [dependencies]
 [dependencies]
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
-codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
-sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+codec = { package = 'parity-scale-codec', version = '1.3.4', default-features = false, features = ['derive'] }
+sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 stake = { package = 'pallet-stake', default-features = false, path = '../stake'}
 stake = { package = 'pallet-stake', default-features = false, path = '../stake'}
 
 
 [dev-dependencies]
 [dev-dependencies]
 mockall = "0.7.1"
 mockall = "0.7.1"
-sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 
 
 [features]
 [features]
 default = ['std']
 default = ['std']
@@ -27,7 +27,7 @@ std = [
 	'codec/std',
 	'codec/std',
 	'sp-std/std',
 	'sp-std/std',
 	'frame-support/std',
 	'frame-support/std',
-	'system/std',
+	'frame-system/std',
 	'sp-arithmetic/std',
 	'sp-arithmetic/std',
 	'sp-runtime/std',
 	'sp-runtime/std',
 	'stake/std',
 	'stake/std',

+ 14 - 13
runtime-modules/hiring/src/lib.rs

@@ -48,7 +48,7 @@ mod test;
 pub use hiring::*;
 pub use hiring::*;
 
 
 /// Main trait of hiring substrate module
 /// Main trait of hiring substrate module
-pub trait Trait: system::Trait + stake::Trait + Sized {
+pub trait Trait: frame_system::Trait + stake::Trait + Sized {
     /// OpeningId type
     /// OpeningId type
     type OpeningId: Parameter
     type OpeningId: Parameter
         + Member
         + Member
@@ -179,7 +179,7 @@ impl<T: Trait> Module<T> {
         role_staking_policy: Option<StakingPolicy<BalanceOf<T>, T::BlockNumber>>,
         role_staking_policy: Option<StakingPolicy<BalanceOf<T>, T::BlockNumber>>,
         human_readable_text: Vec<u8>,
         human_readable_text: Vec<u8>,
     ) -> Result<T::OpeningId, AddOpeningError> {
     ) -> Result<T::OpeningId, AddOpeningError> {
-        let current_block_height = <system::Module<T>>::block_number();
+        let current_block_height = <frame_system::Module<T>>::block_number();
 
 
         Self::ensure_can_add_opening(
         Self::ensure_can_add_opening(
             current_block_height,
             current_block_height,
@@ -240,7 +240,7 @@ impl<T: Trait> Module<T> {
         )?;
         )?;
 
 
         //
         //
-        let current_block_height = <system::Module<T>>::block_number(); // move later!
+        let current_block_height = <frame_system::Module<T>>::block_number(); // move later!
         let new_active_stage = active_stage.new_stage_on_cancelling(current_block_height)?;
         let new_active_stage = active_stage.new_stage_on_cancelling(current_block_height)?;
 
 
         // Ensure unstaking periods are OK.
         // Ensure unstaking periods are OK.
@@ -316,7 +316,7 @@ impl<T: Trait> Module<T> {
         // == MUTATION SAFE ==
         // == MUTATION SAFE ==
         //
         //
 
 
-        let current_block_height = <system::Module<T>>::block_number();
+        let current_block_height = <frame_system::Module<T>>::block_number();
 
 
         // Update state of opening
         // Update state of opening
         let new_opening = opening.clone_with_new_active_opening_stage(
         let new_opening = opening.clone_with_new_active_opening_stage(
@@ -354,7 +354,7 @@ impl<T: Trait> Module<T> {
         // == MUTATION SAFE ==
         // == MUTATION SAFE ==
         //
         //
 
 
-        let current_block_height = <system::Module<T>>::block_number();
+        let current_block_height = <frame_system::Module<T>>::block_number();
 
 
         let new_opening =
         let new_opening =
             opening.clone_with_new_active_opening_stage(hiring::ActiveOpeningStage::ReviewPeriod {
             opening.clone_with_new_active_opening_stage(hiring::ActiveOpeningStage::ReviewPeriod {
@@ -494,7 +494,7 @@ impl<T: Trait> Module<T> {
         );
         );
 
 
         // Grab current block height
         // Grab current block height
-        let current_block_height = <system::Module<T>>::block_number();
+        let current_block_height = <frame_system::Module<T>>::block_number();
         // Get opening with updated counters
         // Get opening with updated counters
         let opening_needed_for_data = <OpeningById<T>>::get(opening_id);
         let opening_needed_for_data = <OpeningById<T>>::get(opening_id);
 
 
@@ -650,7 +650,7 @@ impl<T: Trait> Module<T> {
         );
         );
 
 
         // Grab current block height
         // Grab current block height
-        let current_block_height = <system::Module<T>>::block_number();
+        let current_block_height = <frame_system::Module<T>>::block_number();
 
 
         // Compute index for this new application
         // Compute index for this new application
         let application_index_in_opening =
         let application_index_in_opening =
@@ -794,7 +794,7 @@ impl<T: Trait> Module<T> {
 
 
         // Drop stake from stake to application map
         // Drop stake from stake to application map
         <ApplicationIdByStakingId<T>>::remove(stake_id);
         <ApplicationIdByStakingId<T>>::remove(stake_id);
-        let current_block_height = <system::Module<T>>::block_number();
+        let current_block_height = <frame_system::Module<T>>::block_number();
 
 
         // New application computed
         // New application computed
         let mut new_application = application.clone();
         let mut new_application = application.clone();
@@ -944,11 +944,12 @@ pub enum ApplicationWouldGetAddedEvaluation<T: Trait> {
 
 
 /// Balance alias
 /// Balance alias
 pub type BalanceOf<T> =
 pub type BalanceOf<T> =
-    <<T as stake::Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
+    <<T as stake::Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
 
 
 /// Balance alias for staking
 /// Balance alias for staking
-pub type NegativeImbalance<T> =
-    <<T as stake::Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;
+pub type NegativeImbalance<T> = <<T as stake::Trait>::Currency as Currency<
+    <T as frame_system::Trait>::AccountId,
+>>::NegativeImbalance;
 
 
 /*
 /*
  *  ======== ======== ======== ======== =======
  *  ======== ======== ======== ======== =======
@@ -966,7 +967,7 @@ type ApplicationBTreeMap<T> = BTreeMap<
     <T as Trait>::ApplicationId,
     <T as Trait>::ApplicationId,
     hiring::Application<
     hiring::Application<
         <T as Trait>::OpeningId,
         <T as Trait>::OpeningId,
-        <T as system::Trait>::BlockNumber,
+        <T as frame_system::Trait>::BlockNumber,
         <T as stake::Trait>::StakeId,
         <T as stake::Trait>::StakeId,
     >,
     >,
 >;
 >;
@@ -1144,7 +1145,7 @@ impl<T: Trait> Module<T> {
                 let was_unstaked = application_was_unstaked || role_was_unstaked;
                 let was_unstaked = application_was_unstaked || role_was_unstaked;
 
 
                 // Grab current block height
                 // Grab current block height
-                let current_block_height = <system::Module<T>>::block_number();
+                let current_block_height = <frame_system::Module<T>>::block_number();
 
 
                 /*
                 /*
                  * TODO:
                  * TODO:

+ 8 - 5
runtime-modules/hiring/src/mock.rs

@@ -31,7 +31,7 @@ parameter_types! {
 #[derive(Clone, PartialEq, Eq, Debug)]
 #[derive(Clone, PartialEq, Eq, Debug)]
 pub struct Test;
 pub struct Test;
 
 
-impl system::Trait for Test {
+impl frame_system::Trait for Test {
     type BaseCallFilter = ();
     type BaseCallFilter = ();
     type Origin = Origin;
     type Origin = Origin;
     type Call = ();
     type Call = ();
@@ -52,10 +52,11 @@ impl system::Trait for Test {
     type MaximumBlockLength = MaximumBlockLength;
     type MaximumBlockLength = MaximumBlockLength;
     type AvailableBlockRatio = AvailableBlockRatio;
     type AvailableBlockRatio = AvailableBlockRatio;
     type Version = ();
     type Version = ();
-    type ModuleToIndex = ();
+    type PalletInfo = ();
     type AccountData = balances::AccountData<u64>;
     type AccountData = balances::AccountData<u64>;
     type OnNewAccount = ();
     type OnNewAccount = ();
     type OnKilledAccount = ();
     type OnKilledAccount = ();
+    type SystemWeightInfo = ();
 }
 }
 
 
 parameter_types! {
 parameter_types! {
@@ -69,6 +70,8 @@ impl balances::Trait for Test {
     type Event = ();
     type Event = ();
     type ExistentialDeposit = ExistentialDeposit;
     type ExistentialDeposit = ExistentialDeposit;
     type AccountStore = System;
     type AccountStore = System;
+    type WeightInfo = ();
+    type MaxLocks = ();
 }
 }
 
 
 impl Trait for Test {
 impl Trait for Test {
@@ -87,7 +90,7 @@ impl stake::Trait for Test {
 }
 }
 
 
 pub type Balances = balances::Module<Test>;
 pub type Balances = balances::Module<Test>;
-pub type System = system::Module<Test>;
+pub type System = frame_system::Module<Test>;
 pub type Hiring = Module<Test>;
 pub type Hiring = Module<Test>;
 
 
 // Intercepts panic method
 // Intercepts panic method
@@ -141,7 +144,7 @@ pub(crate) fn test_expectation_and_clear_mock() {
 }
 }
 
 
 pub fn build_test_externalities() -> sp_io::TestExternalities {
 pub fn build_test_externalities() -> sp_io::TestExternalities {
-    let t = system::GenesisConfig::default()
+    let t = frame_system::GenesisConfig::default()
         .build_storage::<Test>()
         .build_storage::<Test>()
         .unwrap();
         .unwrap();
 
 
@@ -195,4 +198,4 @@ impl TestApplicationDeactivatedHandler {
 }
 }
 
 
 // Test fixtures starting block.
 // Test fixtures starting block.
-pub(crate) static FIRST_BLOCK_HEIGHT: <Test as system::Trait>::BlockNumber = 0;
+pub(crate) static FIRST_BLOCK_HEIGHT: <Test as frame_system::Trait>::BlockNumber = 0;

+ 4 - 3
runtime-modules/hiring/src/test/mod.rs

@@ -15,10 +15,11 @@ use std::panic;
 
 
 pub(crate) type OpeningId = <Test as Trait>::OpeningId;
 pub(crate) type OpeningId = <Test as Trait>::OpeningId;
 pub(crate) type ApplicationId = <Test as Trait>::ApplicationId;
 pub(crate) type ApplicationId = <Test as Trait>::ApplicationId;
-pub(crate) type BlockNumber = <Test as system::Trait>::BlockNumber;
+pub(crate) type BlockNumber = <Test as frame_system::Trait>::BlockNumber;
 pub(crate) type StakeId = <Test as stake::Trait>::StakeId;
 pub(crate) type StakeId = <Test as stake::Trait>::StakeId;
-pub(crate) type Balance =
-    <<Test as stake::Trait>::Currency as Currency<<Test as system::Trait>::AccountId>>::Balance;
+pub(crate) type Balance = <<Test as stake::Trait>::Currency as Currency<
+    <Test as frame_system::Trait>::AccountId,
+>>::Balance;
 
 
 // Debug test object content. Recurring temporary usage - do not delete.
 // Debug test object content. Recurring temporary usage - do not delete.
 #[allow(dead_code)]
 #[allow(dead_code)]

+ 12 - 12
runtime-modules/membership/Cargo.toml

@@ -1,24 +1,24 @@
 [package]
 [package]
 name = 'pallet-membership'
 name = 'pallet-membership'
-version = '3.0.0'
+version = '3.1.0'
 authors = ['Joystream contributors']
 authors = ['Joystream contributors']
 edition = '2018'
 edition = '2018'
 
 
 [dependencies]
 [dependencies]
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
-codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
-sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+codec = { package = 'parity-scale-codec', version = '1.3.4', default-features = false, features = ['derive'] }
+sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 common = { package = 'pallet-common', default-features = false, path = '../common'}
 common = { package = 'pallet-common', default-features = false, path = '../common'}
 
 
 [dev-dependencies]
 [dev-dependencies]
-sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 
 
 [features]
 [features]
 default = ['std']
 default = ['std']
@@ -26,7 +26,7 @@ std = [
 	'serde',
 	'serde',
 	'codec/std',
 	'codec/std',
 	'frame-support/std',
 	'frame-support/std',
-	'system/std',
+	'frame-system/std',
 	'sp-std/std',
 	'sp-std/std',
 	'sp-arithmetic/std',
 	'sp-arithmetic/std',
 	'sp-runtime/std',
 	'sp-runtime/std',

+ 8 - 8
runtime-modules/membership/src/lib.rs

@@ -12,12 +12,12 @@ mod tests;
 use codec::{Codec, Decode, Encode};
 use codec::{Codec, Decode, Encode};
 use frame_support::traits::Currency;
 use frame_support::traits::Currency;
 use frame_support::{decl_event, decl_module, decl_storage, ensure, Parameter};
 use frame_support::{decl_event, decl_module, decl_storage, ensure, Parameter};
+use frame_system::{ensure_root, ensure_signed};
 use sp_arithmetic::traits::{BaseArithmetic, One};
 use sp_arithmetic::traits::{BaseArithmetic, One};
 use sp_runtime::traits::{MaybeSerialize, Member};
 use sp_runtime::traits::{MaybeSerialize, Member};
 use sp_std::borrow::ToOwned;
 use sp_std::borrow::ToOwned;
 use sp_std::vec;
 use sp_std::vec;
 use sp_std::vec::Vec;
 use sp_std::vec::Vec;
-use system::{ensure_root, ensure_signed};
 
 
 use common::currency::{BalanceOf, GovernanceCurrency};
 use common::currency::{BalanceOf, GovernanceCurrency};
 
 
@@ -25,8 +25,8 @@ use common::currency::{BalanceOf, GovernanceCurrency};
 /// Result with string error message. This exists for backward compatibility purpose.
 /// Result with string error message. This exists for backward compatibility purpose.
 pub type DispatchResult = Result<(), &'static str>;
 pub type DispatchResult = Result<(), &'static str>;
 
 
-pub trait Trait: system::Trait + GovernanceCurrency + pallet_timestamp::Trait {
-    type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
+pub trait Trait: frame_system::Trait + GovernanceCurrency + pallet_timestamp::Trait {
+    type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
 
 
     type MemberId: Parameter
     type MemberId: Parameter
         + Member
         + Member
@@ -80,11 +80,11 @@ const DEFAULT_MAX_ABOUT_TEXT_LENGTH: u32 = 2048;
 
 
 /// Public membership object alias.
 /// Public membership object alias.
 pub type Membership<T> = MembershipObject<
 pub type Membership<T> = MembershipObject<
-    <T as system::Trait>::BlockNumber,
+    <T as frame_system::Trait>::BlockNumber,
     <T as pallet_timestamp::Trait>::Moment,
     <T as pallet_timestamp::Trait>::Moment,
     <T as Trait>::PaidTermId,
     <T as Trait>::PaidTermId,
     <T as Trait>::SubscriptionId,
     <T as Trait>::SubscriptionId,
-    <T as system::Trait>::AccountId,
+    <T as frame_system::Trait>::AccountId,
 >;
 >;
 
 
 #[derive(Encode, Decode, Default)]
 #[derive(Encode, Decode, Default)]
@@ -243,7 +243,7 @@ decl_storage! {
 
 
 decl_event! {
 decl_event! {
     pub enum Event<T> where
     pub enum Event<T> where
-      <T as system::Trait>::AccountId,
+      <T as frame_system::Trait>::AccountId,
       <T as Trait>::MemberId,
       <T as Trait>::MemberId,
     {
     {
         MemberRegistered(MemberId, AccountId),
         MemberRegistered(MemberId, AccountId),
@@ -286,7 +286,7 @@ decl_module! {
                 &who,
                 &who,
                 &user_info,
                 &user_info,
                 EntryMethod::Paid(paid_terms_id),
                 EntryMethod::Paid(paid_terms_id),
-                <system::Module<T>>::block_number(),
+                <frame_system::Module<T>>::block_number(),
                 <pallet_timestamp::Module<T>>::now()
                 <pallet_timestamp::Module<T>>::now()
             )?;
             )?;
 
 
@@ -434,7 +434,7 @@ decl_module! {
                 &new_member_account,
                 &new_member_account,
                 &user_info,
                 &user_info,
                 EntryMethod::Screening(sender),
                 EntryMethod::Screening(sender),
-                <system::Module<T>>::block_number(),
+                <frame_system::Module<T>>::block_number(),
                 <pallet_timestamp::Module<T>>::now()
                 <pallet_timestamp::Module<T>>::now()
             )?;
             )?;
 
 

+ 10 - 6
runtime-modules/membership/src/mock.rs

@@ -4,13 +4,13 @@ pub use crate::{GenesisConfig, Trait, DEFAULT_PAID_TERM_ID};
 
 
 pub use frame_support::traits::Currency;
 pub use frame_support::traits::Currency;
 use frame_support::{impl_outer_origin, parameter_types};
 use frame_support::{impl_outer_origin, parameter_types};
+pub use frame_system;
 use sp_core::H256;
 use sp_core::H256;
 use sp_runtime::{
 use sp_runtime::{
     testing::Header,
     testing::Header,
     traits::{BlakeTwo256, IdentityLookup},
     traits::{BlakeTwo256, IdentityLookup},
     Perbill,
     Perbill,
 };
 };
-pub use system;
 
 
 pub use common::currency::GovernanceCurrency;
 pub use common::currency::GovernanceCurrency;
 
 
@@ -29,7 +29,7 @@ parameter_types! {
     pub const MinimumPeriod: u64 = 5;
     pub const MinimumPeriod: u64 = 5;
 }
 }
 
 
-impl system::Trait for Test {
+impl frame_system::Trait for Test {
     type BaseCallFilter = ();
     type BaseCallFilter = ();
     type Origin = Origin;
     type Origin = Origin;
     type Call = ();
     type Call = ();
@@ -50,16 +50,18 @@ impl system::Trait for Test {
     type MaximumBlockLength = MaximumBlockLength;
     type MaximumBlockLength = MaximumBlockLength;
     type AvailableBlockRatio = AvailableBlockRatio;
     type AvailableBlockRatio = AvailableBlockRatio;
     type Version = ();
     type Version = ();
-    type ModuleToIndex = ();
+    type PalletInfo = ();
     type AccountData = balances::AccountData<u64>;
     type AccountData = balances::AccountData<u64>;
     type OnNewAccount = ();
     type OnNewAccount = ();
     type OnKilledAccount = ();
     type OnKilledAccount = ();
+    type SystemWeightInfo = ();
 }
 }
 
 
 impl pallet_timestamp::Trait for Test {
 impl pallet_timestamp::Trait for Test {
     type Moment = u64;
     type Moment = u64;
     type OnTimestampSet = ();
     type OnTimestampSet = ();
     type MinimumPeriod = MinimumPeriod;
     type MinimumPeriod = MinimumPeriod;
+    type WeightInfo = ();
 }
 }
 
 
 parameter_types! {
 parameter_types! {
@@ -72,6 +74,8 @@ impl balances::Trait for Test {
     type Event = ();
     type Event = ();
     type ExistentialDeposit = ExistentialDeposit;
     type ExistentialDeposit = ExistentialDeposit;
     type AccountStore = System;
     type AccountStore = System;
+    type WeightInfo = ();
+    type MaxLocks = ();
 }
 }
 
 
 impl GovernanceCurrency for Test {
 impl GovernanceCurrency for Test {
@@ -87,7 +91,7 @@ impl Trait for Test {
 }
 }
 
 
 pub struct TestExternalitiesBuilder<T: Trait> {
 pub struct TestExternalitiesBuilder<T: Trait> {
-    system_config: Option<system::GenesisConfig>,
+    system_config: Option<frame_system::GenesisConfig>,
     membership_config: Option<GenesisConfig<T>>,
     membership_config: Option<GenesisConfig<T>>,
 }
 }
 
 
@@ -109,7 +113,7 @@ impl<T: Trait> TestExternalitiesBuilder<T> {
         // Add system
         // Add system
         let mut t = self
         let mut t = self
             .system_config
             .system_config
-            .unwrap_or(system::GenesisConfig::default())
+            .unwrap_or(frame_system::GenesisConfig::default())
             .build_storage::<T>()
             .build_storage::<T>()
             .unwrap();
             .unwrap();
 
 
@@ -125,4 +129,4 @@ impl<T: Trait> TestExternalitiesBuilder<T> {
 
 
 pub type Balances = balances::Module<Test>;
 pub type Balances = balances::Module<Test>;
 pub type Members = crate::Module<Test>;
 pub type Members = crate::Module<Test>;
-pub type System = system::Module<Test>;
+pub type System = frame_system::Module<Test>;

+ 7 - 7
runtime-modules/memo/Cargo.toml

@@ -1,15 +1,15 @@
 [package]
 [package]
 name = 'pallet-memo'
 name = 'pallet-memo'
-version = '3.0.0'
+version = '3.1.0'
 authors = ['Joystream contributors']
 authors = ['Joystream contributors']
 edition = '2018'
 edition = '2018'
 
 
 [dependencies]
 [dependencies]
-codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
-sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+codec = { package = 'parity-scale-codec', version = '1.3.4', default-features = false, features = ['derive'] }
+sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 common = { package = 'pallet-common', default-features = false, path = '../common'}
 common = { package = 'pallet-common', default-features = false, path = '../common'}
 
 
 [features]
 [features]
@@ -19,6 +19,6 @@ std = [
 	'sp-arithmetic/std',
 	'sp-arithmetic/std',
 	'sp-std/std',
 	'sp-std/std',
 	'frame-support/std',
 	'frame-support/std',
-	'system/std',
+	'frame-system/std',
 	'common/std',
 	'common/std',
 ]
 ]

+ 4 - 4
runtime-modules/memo/src/lib.rs

@@ -3,14 +3,14 @@
 
 
 use frame_support::traits::Currency;
 use frame_support::traits::Currency;
 use frame_support::{decl_event, decl_module, decl_storage, ensure};
 use frame_support::{decl_event, decl_module, decl_storage, ensure};
+use frame_system::ensure_signed;
 use sp_arithmetic::traits::Zero;
 use sp_arithmetic::traits::Zero;
 use sp_std::vec::Vec;
 use sp_std::vec::Vec;
-use system::ensure_signed;
 
 
 use common::currency::GovernanceCurrency;
 use common::currency::GovernanceCurrency;
 
 
-pub trait Trait: system::Trait + GovernanceCurrency {
-    type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
+pub trait Trait: frame_system::Trait + GovernanceCurrency {
+    type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
 }
 }
 
 
 pub type MemoText = Vec<u8>;
 pub type MemoText = Vec<u8>;
@@ -23,7 +23,7 @@ decl_storage! {
 }
 }
 
 
 decl_event! {
 decl_event! {
-    pub enum Event<T> where <T as system::Trait>::AccountId {
+    pub enum Event<T> where <T as frame_system::Trait>::AccountId {
         MemoUpdated(AccountId),
         MemoUpdated(AccountId),
     }
     }
 }
 }

+ 15 - 15
runtime-modules/proposals/codex/Cargo.toml

@@ -1,20 +1,20 @@
 [package]
 [package]
 name = 'pallet-proposals-codex'
 name = 'pallet-proposals-codex'
-version = '3.0.0'
+version = '3.1.0'
 authors = ['Joystream contributors']
 authors = ['Joystream contributors']
 edition = '2018'
 edition = '2018'
 
 
 [dependencies]
 [dependencies]
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
-codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
-sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-staking = { package = 'pallet-staking', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+codec = { package = 'parity-scale-codec', version = '1.3.4', default-features = false, features = ['derive'] }
+sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+staking = { package = 'pallet-staking', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 membership = { package = 'pallet-membership', default-features = false, path = '../../membership'}
 membership = { package = 'pallet-membership', default-features = false, path = '../../membership'}
 stake = { package = 'pallet-stake', default-features = false, path = '../../stake'}
 stake = { package = 'pallet-stake', default-features = false, path = '../../stake'}
 governance = { package = 'pallet-governance', default-features = false, path = '../../governance'}
 governance = { package = 'pallet-governance', default-features = false, path = '../../governance'}
@@ -26,10 +26,10 @@ proposals-engine = { package = 'pallet-proposals-engine', default-features = fal
 proposals-discussion = { package = 'pallet-proposals-discussion', default-features = false, path = '../discussion'}
 proposals-discussion = { package = 'pallet-proposals-discussion', default-features = false, path = '../discussion'}
 
 
 [dev-dependencies]
 [dev-dependencies]
-sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-staking = { package = 'sp-staking', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-staking-reward-curve = { package = 'pallet-staking-reward-curve', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-staking = { package = 'sp-staking', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-staking-reward-curve = { package = 'pallet-staking-reward-curve', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 recurring-rewards = { package = 'pallet-recurring-reward', default-features = false, path = '../../recurring-reward'}
 recurring-rewards = { package = 'pallet-recurring-reward', default-features = false, path = '../../recurring-reward'}
 strum = {version = "0.19", default-features = false}
 strum = {version = "0.19", default-features = false}
 
 
@@ -42,7 +42,7 @@ std = [
     'frame-support/std',
     'frame-support/std',
     'sp-arithmetic/std',
     'sp-arithmetic/std',
     'sp-runtime/std',
     'sp-runtime/std',
-    'system/std',
+    'frame-system/std',
     'staking/std',
     'staking/std',
     'pallet-timestamp/std',
     'pallet-timestamp/std',
     'balances/std',
     'balances/std',

+ 9 - 8
runtime-modules/proposals/codex/src/lib.rs

@@ -64,11 +64,11 @@ mod tests;
 use frame_support::dispatch::DispatchResult;
 use frame_support::dispatch::DispatchResult;
 use frame_support::traits::{Currency, Get};
 use frame_support::traits::{Currency, Get};
 use frame_support::{decl_error, decl_module, decl_storage, ensure, print};
 use frame_support::{decl_error, decl_module, decl_storage, ensure, print};
+use frame_system::ensure_root;
 use sp_arithmetic::traits::Zero;
 use sp_arithmetic::traits::Zero;
 use sp_std::clone::Clone;
 use sp_std::clone::Clone;
 use sp_std::str::from_utf8;
 use sp_std::str::from_utf8;
 use sp_std::vec::Vec;
 use sp_std::vec::Vec;
-use system::ensure_root;
 
 
 use common::origin::ActorOriginValidator;
 use common::origin::ActorOriginValidator;
 use common::working_group::WorkingGroup;
 use common::working_group::WorkingGroup;
@@ -134,7 +134,7 @@ struct CreateProposalParameters<T: Trait> {
 
 
 /// 'Proposals codex' substrate module Trait
 /// 'Proposals codex' substrate module Trait
 pub trait Trait:
 pub trait Trait:
-    system::Trait
+    frame_system::Trait
     + proposals_engine::Trait
     + proposals_engine::Trait
     + proposals_discussion::Trait
     + proposals_discussion::Trait
     + membership::Trait
     + membership::Trait
@@ -161,7 +161,7 @@ pub trait Trait:
 
 
 /// Balance alias for `stake` module
 /// Balance alias for `stake` module
 pub type BalanceOf<T> =
 pub type BalanceOf<T> =
-    <<T as stake::Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
+    <<T as stake::Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
 
 
 /// Currency alias for `stake` module
 /// Currency alias for `stake` module
 pub type CurrencyOf<T> = <T as stake::Trait>::Currency;
 pub type CurrencyOf<T> = <T as stake::Trait>::Currency;
@@ -169,16 +169,17 @@ pub type CurrencyOf<T> = <T as stake::Trait>::Currency;
 /// Balance alias for GovernanceCurrency from `common` module. TODO: replace with BalanceOf
 /// Balance alias for GovernanceCurrency from `common` module. TODO: replace with BalanceOf
 pub type BalanceOfGovernanceCurrency<T> =
 pub type BalanceOfGovernanceCurrency<T> =
     <<T as common::currency::GovernanceCurrency>::Currency as Currency<
     <<T as common::currency::GovernanceCurrency>::Currency as Currency<
-        <T as system::Trait>::AccountId,
+        <T as frame_system::Trait>::AccountId,
     >>::Balance;
     >>::Balance;
 
 
 /// Balance alias for token mint balance from `token mint` module. TODO: replace with BalanceOf
 /// Balance alias for token mint balance from `token mint` module. TODO: replace with BalanceOf
 pub type BalanceOfMint<T> =
 pub type BalanceOfMint<T> =
-    <<T as minting::Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
+    <<T as minting::Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
 
 
 /// Negative imbalance alias for staking
 /// Negative imbalance alias for staking
-pub type NegativeImbalance<T> =
-    <<T as stake::Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;
+pub type NegativeImbalance<T> = <<T as stake::Trait>::Currency as Currency<
+    <T as frame_system::Trait>::AccountId,
+>>::NegativeImbalance;
 
 
 type MemberId<T> = <T as membership::Trait>::MemberId;
 type MemberId<T> = <T as membership::Trait>::MemberId;
 
 
@@ -804,7 +805,7 @@ decl_module! {
 
 
             print("Runtime upgrade proposal execution started.");
             print("Runtime upgrade proposal execution started.");
 
 
-            <system::Module<T>>::set_code(cloned_origin2, wasm)?;
+            <frame_system::Module<T>>::set_code(cloned_origin2, wasm)?;
 
 
             print("Runtime upgrade proposal execution finished.");
             print("Runtime upgrade proposal execution finished.");
         }
         }

+ 2 - 2
runtime-modules/proposals/codex/src/proposal_types/mod.rs

@@ -20,8 +20,8 @@ pub trait ProposalEncoder<T: crate::Trait> {
 pub type ProposalDetailsOf<T> = ProposalDetails<
 pub type ProposalDetailsOf<T> = ProposalDetails<
     crate::BalanceOfMint<T>,
     crate::BalanceOfMint<T>,
     crate::BalanceOfGovernanceCurrency<T>,
     crate::BalanceOfGovernanceCurrency<T>,
-    <T as system::Trait>::BlockNumber,
-    <T as system::Trait>::AccountId,
+    <T as frame_system::Trait>::BlockNumber,
+    <T as frame_system::Trait>::AccountId,
     working_group::OpeningId<T>,
     working_group::OpeningId<T>,
     working_group::ApplicationId<T>,
     working_group::ApplicationId<T>,
     crate::BalanceOf<T>,
     crate::BalanceOf<T>,

+ 14 - 9
runtime-modules/proposals/codex/src/tests/mock.rs

@@ -1,6 +1,7 @@
 #![cfg(test)]
 #![cfg(test)]
 
 
 use frame_support::{impl_outer_dispatch, impl_outer_origin, parameter_types};
 use frame_support::{impl_outer_dispatch, impl_outer_origin, parameter_types};
+pub use frame_system;
 use sp_core::H256;
 use sp_core::H256;
 use sp_runtime::curve::PiecewiseLinear;
 use sp_runtime::curve::PiecewiseLinear;
 use sp_runtime::{
 use sp_runtime::{
@@ -9,7 +10,6 @@ use sp_runtime::{
     Perbill,
     Perbill,
 };
 };
 use sp_staking::SessionIndex;
 use sp_staking::SessionIndex;
-pub use system;
 
 
 use crate::{ProposalDetailsOf, ProposalEncoder};
 use crate::{ProposalDetailsOf, ProposalEncoder};
 use proposals_engine::VotersParameters;
 use proposals_engine::VotersParameters;
@@ -36,7 +36,7 @@ impl_outer_dispatch! {
         codex::ProposalCodex,
         codex::ProposalCodex,
         proposals::ProposalsEngine,
         proposals::ProposalsEngine,
         staking::Staking,
         staking::Staking,
-        system::System,
+        frame_system::System,
     }
     }
 }
 }
 
 
@@ -62,6 +62,8 @@ impl balances::Trait for Test {
     type Event = ();
     type Event = ();
     type ExistentialDeposit = ExistentialDeposit;
     type ExistentialDeposit = ExistentialDeposit;
     type AccountStore = System;
     type AccountStore = System;
+    type WeightInfo = ();
+    type MaxLocks = ();
 }
 }
 
 
 impl stake::Trait for Test {
 impl stake::Trait for Test {
@@ -113,7 +115,7 @@ impl governance::council::Trait for Test {
 
 
 impl common::origin::ActorOriginValidator<Origin, u64, u64> for () {
 impl common::origin::ActorOriginValidator<Origin, u64, u64> for () {
     fn ensure_actor_origin(origin: Origin, _: u64) -> Result<u64, &'static str> {
     fn ensure_actor_origin(origin: Origin, _: u64) -> Result<u64, &'static str> {
-        let account_id = system::ensure_signed(origin)?;
+        let account_id = frame_system::ensure_signed(origin)?;
 
 
         Ok(account_id)
         Ok(account_id)
     }
     }
@@ -214,7 +216,7 @@ impl staking::Trait for Test {
     type SessionsPerEra = SessionsPerEra;
     type SessionsPerEra = SessionsPerEra;
     type BondingDuration = BondingDuration;
     type BondingDuration = BondingDuration;
     type SlashDeferDuration = ();
     type SlashDeferDuration = ();
-    type SlashCancelOrigin = system::EnsureRoot<Self::AccountId>;
+    type SlashCancelOrigin = frame_system::EnsureRoot<Self::AccountId>;
     type SessionInterface = Self;
     type SessionInterface = Self;
     type RewardCurve = RewardCurve;
     type RewardCurve = RewardCurve;
     type NextNewSession = ();
     type NextNewSession = ();
@@ -224,9 +226,10 @@ impl staking::Trait for Test {
     type MinSolutionScoreBump = ();
     type MinSolutionScoreBump = ();
     type MaxNominatorRewardedPerValidator = ();
     type MaxNominatorRewardedPerValidator = ();
     type UnsignedPriority = ();
     type UnsignedPriority = ();
+    type WeightInfo = ();
 }
 }
 
 
-impl<LocalCall> system::offchain::SendTransactionTypes<LocalCall> for Test
+impl<LocalCall> frame_system::offchain::SendTransactionTypes<LocalCall> for Test
 where
 where
     Call: From<LocalCall>,
     Call: From<LocalCall>,
 {
 {
@@ -263,7 +266,7 @@ impl ProposalEncoder<Test> for () {
     }
     }
 }
 }
 
 
-impl system::Trait for Test {
+impl frame_system::Trait for Test {
     type BaseCallFilter = ();
     type BaseCallFilter = ();
     type Origin = Origin;
     type Origin = Origin;
     type Call = Call;
     type Call = Call;
@@ -284,20 +287,22 @@ impl system::Trait for Test {
     type MaximumBlockLength = MaximumBlockLength;
     type MaximumBlockLength = MaximumBlockLength;
     type AvailableBlockRatio = AvailableBlockRatio;
     type AvailableBlockRatio = AvailableBlockRatio;
     type Version = ();
     type Version = ();
-    type ModuleToIndex = ();
+    type PalletInfo = ();
     type AccountData = balances::AccountData<u64>;
     type AccountData = balances::AccountData<u64>;
     type OnNewAccount = ();
     type OnNewAccount = ();
     type OnKilledAccount = ();
     type OnKilledAccount = ();
+    type SystemWeightInfo = ();
 }
 }
 
 
 impl pallet_timestamp::Trait for Test {
 impl pallet_timestamp::Trait for Test {
     type Moment = u64;
     type Moment = u64;
     type OnTimestampSet = ();
     type OnTimestampSet = ();
     type MinimumPeriod = MinimumPeriod;
     type MinimumPeriod = MinimumPeriod;
+    type WeightInfo = ();
 }
 }
 
 
 pub fn initial_test_ext() -> sp_io::TestExternalities {
 pub fn initial_test_ext() -> sp_io::TestExternalities {
-    let t = system::GenesisConfig::default()
+    let t = frame_system::GenesisConfig::default()
         .build_storage::<Test>()
         .build_storage::<Test>()
         .unwrap();
         .unwrap();
 
 
@@ -309,4 +314,4 @@ pub type ProposalCodex = crate::Module<Test>;
 pub type ProposalsEngine = proposals_engine::Module<Test>;
 pub type ProposalsEngine = proposals_engine::Module<Test>;
 pub type Balances = balances::Module<Test>;
 pub type Balances = balances::Module<Test>;
 pub type Timestamp = pallet_timestamp::Module<Test>;
 pub type Timestamp = pallet_timestamp::Module<Test>;
-pub type System = system::Module<Test>;
+pub type System = frame_system::Module<Test>;

+ 3 - 13
runtime-modules/proposals/codex/src/tests/mod.rs

@@ -3,7 +3,7 @@ mod mock;
 use frame_support::dispatch::{DispatchError, DispatchResult};
 use frame_support::dispatch::{DispatchError, DispatchResult};
 use frame_support::storage::StorageMap;
 use frame_support::storage::StorageMap;
 use frame_support::traits::Currency;
 use frame_support::traits::Currency;
-use system::RawOrigin;
+use frame_system::RawOrigin;
 
 
 use common::working_group::WorkingGroup;
 use common::working_group::WorkingGroup;
 use governance::election_params::ElectionParameters;
 use governance::election_params::ElectionParameters;
@@ -621,17 +621,7 @@ fn create_set_validator_count_proposal_common_checks_succeed() {
 #[test]
 #[test]
 fn create_set_validator_count_proposal_failed_with_invalid_validator_count() {
 fn create_set_validator_count_proposal_failed_with_invalid_validator_count() {
     initial_test_ext().execute_with(|| {
     initial_test_ext().execute_with(|| {
-        assert_eq!(
-            ProposalCodex::create_set_validator_count_proposal(
-                RawOrigin::Signed(1).into(),
-                1,
-                b"title".to_vec(),
-                b"body".to_vec(),
-                Some(<BalanceOf<Test>>::from(500u32)),
-                3,
-            ),
-            Err(Error::<Test>::InvalidValidatorCount.into())
-        );
+        staking::MinimumValidatorCount::put(10);
 
 
         assert_eq!(
         assert_eq!(
             ProposalCodex::create_set_validator_count_proposal(
             ProposalCodex::create_set_validator_count_proposal(
@@ -639,7 +629,7 @@ fn create_set_validator_count_proposal_failed_with_invalid_validator_count() {
                 1,
                 1,
                 b"title".to_vec(),
                 b"title".to_vec(),
                 b"body".to_vec(),
                 b"body".to_vec(),
-                Some(<BalanceOf<Test>>::from(1001u32)),
+                Some(<BalanceOf<Test>>::from(100_000_u32)),
                 3,
                 3,
             ),
             ),
             Err(Error::<Test>::InvalidValidatorCount.into())
             Err(Error::<Test>::InvalidValidatorCount.into())

+ 11 - 11
runtime-modules/proposals/discussion/Cargo.toml

@@ -1,24 +1,24 @@
 [package]
 [package]
 name = 'pallet-proposals-discussion'
 name = 'pallet-proposals-discussion'
-version = '3.0.0'
+version = '3.1.0'
 authors = ['Joystream contributors']
 authors = ['Joystream contributors']
 edition = '2018'
 edition = '2018'
 
 
 [dependencies]
 [dependencies]
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
-codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
-sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+codec = { package = 'parity-scale-codec', version = '1.3.4', default-features = false, features = ['derive'] }
+sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 membership = { package = 'pallet-membership', default-features = false, path = '../../membership'}
 membership = { package = 'pallet-membership', default-features = false, path = '../../membership'}
 common = { package = 'pallet-common', default-features = false, path = '../../common'}
 common = { package = 'pallet-common', default-features = false, path = '../../common'}
 
 
 [dev-dependencies]
 [dev-dependencies]
-sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 
 
 [features]
 [features]
 default = ['std']
 default = ['std']
@@ -27,7 +27,7 @@ std = [
 	'codec/std',
 	'codec/std',
 	'sp-std/std',
 	'sp-std/std',
 	'frame-support/std',
 	'frame-support/std',
-	'system/std',
+	'frame-system/std',
     'membership/std',
     'membership/std',
     'common/std',
     'common/std',
 ]
 ]

+ 5 - 5
runtime-modules/proposals/discussion/src/lib.rs

@@ -20,7 +20,7 @@
 //!
 //!
 //! ```
 //! ```
 //! use frame_support::decl_module;
 //! use frame_support::decl_module;
-//! use system::ensure_root;
+//! use frame_system::ensure_root;
 //! use pallet_proposals_discussion::{self as discussions};
 //! use pallet_proposals_discussion::{self as discussions};
 //!
 //!
 //! pub trait Trait: discussions::Trait + membership::Trait {}
 //! pub trait Trait: discussions::Trait + membership::Trait {}
@@ -79,9 +79,9 @@ decl_event!(
 );
 );
 
 
 /// 'Proposal discussion' substrate module Trait
 /// 'Proposal discussion' substrate module Trait
-pub trait Trait: system::Trait + membership::Trait {
+pub trait Trait: frame_system::Trait + membership::Trait {
     /// Discussion event type.
     /// Discussion event type.
-    type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
+    type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
 
 
     /// Validates post author id and origin combination
     /// Validates post author id and origin combination
     type PostAuthorOriginValidator: ActorOriginValidator<
     type PostAuthorOriginValidator: ActorOriginValidator<
@@ -329,9 +329,9 @@ impl<T: Trait> Module<T> {
 }
 }
 
 
 impl<T: Trait> Module<T> {
 impl<T: Trait> Module<T> {
-    // Wrapper-function over system::block_number()
+    // Wrapper-function over System::block_number()
     fn current_block() -> T::BlockNumber {
     fn current_block() -> T::BlockNumber {
-        <system::Module<T>>::block_number()
+        <frame_system::Module<T>>::block_number()
     }
     }
 
 
     // returns incremented thread counter if last thread author equals with provided parameter
     // returns incremented thread counter if last thread author equals with provided parameter

+ 11 - 7
runtime-modules/proposals/discussion/src/tests/mock.rs

@@ -1,6 +1,6 @@
 #![cfg(test)]
 #![cfg(test)]
 
 
-pub use system;
+pub use frame_system;
 
 
 use frame_support::traits::{OnFinalize, OnInitialize};
 use frame_support::traits::{OnFinalize, OnInitialize};
 use frame_support::{impl_outer_event, impl_outer_origin, parameter_types};
 use frame_support::{impl_outer_event, impl_outer_origin, parameter_types};
@@ -49,7 +49,7 @@ impl_outer_event! {
         discussion<T>,
         discussion<T>,
         balances<T>,
         balances<T>,
         membership_mod<T>,
         membership_mod<T>,
-        system<T>,
+        frame_system<T>,
     }
     }
 }
 }
 
 
@@ -65,6 +65,8 @@ impl balances::Trait for Test {
     type Event = TestEvent;
     type Event = TestEvent;
     type ExistentialDeposit = ExistentialDeposit;
     type ExistentialDeposit = ExistentialDeposit;
     type AccountStore = System;
     type AccountStore = System;
+    type WeightInfo = ();
+    type MaxLocks = ();
 }
 }
 
 
 impl common::currency::GovernanceCurrency for Test {
 impl common::currency::GovernanceCurrency for Test {
@@ -92,7 +94,7 @@ impl crate::Trait for Test {
 
 
 impl ActorOriginValidator<Origin, u64, u64> for () {
 impl ActorOriginValidator<Origin, u64, u64> for () {
     fn ensure_actor_origin(origin: Origin, actor_id: u64) -> Result<u64, &'static str> {
     fn ensure_actor_origin(origin: Origin, actor_id: u64) -> Result<u64, &'static str> {
-        if system::ensure_none(origin).is_ok() {
+        if frame_system::ensure_none(origin).is_ok() {
             return Ok(1);
             return Ok(1);
         }
         }
 
 
@@ -104,7 +106,7 @@ impl ActorOriginValidator<Origin, u64, u64> for () {
     }
     }
 }
 }
 
 
-impl system::Trait for Test {
+impl frame_system::Trait for Test {
     type BaseCallFilter = ();
     type BaseCallFilter = ();
     type Origin = Origin;
     type Origin = Origin;
     type Call = ();
     type Call = ();
@@ -125,20 +127,22 @@ impl system::Trait for Test {
     type MaximumBlockLength = MaximumBlockLength;
     type MaximumBlockLength = MaximumBlockLength;
     type AvailableBlockRatio = AvailableBlockRatio;
     type AvailableBlockRatio = AvailableBlockRatio;
     type Version = ();
     type Version = ();
-    type ModuleToIndex = ();
+    type PalletInfo = ();
     type AccountData = balances::AccountData<u64>;
     type AccountData = balances::AccountData<u64>;
     type OnNewAccount = ();
     type OnNewAccount = ();
     type OnKilledAccount = ();
     type OnKilledAccount = ();
+    type SystemWeightInfo = ();
 }
 }
 
 
 impl pallet_timestamp::Trait for Test {
 impl pallet_timestamp::Trait for Test {
     type Moment = u64;
     type Moment = u64;
     type OnTimestampSet = ();
     type OnTimestampSet = ();
     type MinimumPeriod = MinimumPeriod;
     type MinimumPeriod = MinimumPeriod;
+    type WeightInfo = ();
 }
 }
 
 
 pub fn initial_test_ext() -> sp_io::TestExternalities {
 pub fn initial_test_ext() -> sp_io::TestExternalities {
-    let t = system::GenesisConfig::default()
+    let t = frame_system::GenesisConfig::default()
         .build_storage::<Test>()
         .build_storage::<Test>()
         .unwrap();
         .unwrap();
 
 
@@ -146,7 +150,7 @@ pub fn initial_test_ext() -> sp_io::TestExternalities {
 }
 }
 
 
 pub type Discussions = crate::Module<Test>;
 pub type Discussions = crate::Module<Test>;
-pub type System = system::Module<Test>;
+pub type System = frame_system::Module<Test>;
 
 
 // Recommendation from Parity on testing on_finalize
 // Recommendation from Parity on testing on_finalize
 // https://substrate.dev/docs/en/next/development/module/tests
 // https://substrate.dev/docs/en/next/development/module/tests

+ 2 - 2
runtime-modules/proposals/discussion/src/tests/mod.rs

@@ -1,8 +1,8 @@
 mod mock;
 mod mock;
 
 
 use frame_support::dispatch::{DispatchError, DispatchResult};
 use frame_support::dispatch::{DispatchError, DispatchResult};
-use system::RawOrigin;
-use system::{EventRecord, Phase};
+use frame_system::RawOrigin;
+use frame_system::{EventRecord, Phase};
 
 
 use crate::*;
 use crate::*;
 use mock::*;
 use mock::*;

+ 12 - 12
runtime-modules/proposals/engine/Cargo.toml

@@ -1,27 +1,27 @@
 [package]
 [package]
 name = 'pallet-proposals-engine'
 name = 'pallet-proposals-engine'
-version = '3.0.0'
+version = '3.1.0'
 authors = ['Joystream contributors']
 authors = ['Joystream contributors']
 edition = '2018'
 edition = '2018'
 
 
 [dependencies]
 [dependencies]
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
-codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
-sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+codec = { package = 'parity-scale-codec', version = '1.3.4', default-features = false, features = ['derive'] }
+sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 membership = { package = 'pallet-membership', default-features = false, path = '../../membership'}
 membership = { package = 'pallet-membership', default-features = false, path = '../../membership'}
 stake = { package = 'pallet-stake', default-features = false, path = '../../stake'}
 stake = { package = 'pallet-stake', default-features = false, path = '../../stake'}
 common = { package = 'pallet-common', default-features = false, path = '../../common'}
 common = { package = 'pallet-common', default-features = false, path = '../../common'}
 
 
 [dev-dependencies]
 [dev-dependencies]
 mockall = "0.7.1"
 mockall = "0.7.1"
-sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 
 
 [features]
 [features]
 default = ['std']
 default = ['std']
@@ -30,7 +30,7 @@ std = [
 	'codec/std',
 	'codec/std',
 	'sp-std/std',
 	'sp-std/std',
 	'frame-support/std',
 	'frame-support/std',
-	'system/std',
+	'frame-system/std',
 	'pallet-timestamp/std',
 	'pallet-timestamp/std',
 	'sp-arithmetic/std',
 	'sp-arithmetic/std',
 	'sp-runtime/std',
 	'sp-runtime/std',

+ 14 - 14
runtime-modules/proposals/engine/src/lib.rs

@@ -58,7 +58,7 @@
 //!
 //!
 //! ```
 //! ```
 //! use frame_support::{decl_module, print};
 //! use frame_support::{decl_module, print};
-//! use system::ensure_signed;
+//! use frame_system::ensure_signed;
 //! use codec::Encode;
 //! use codec::Encode;
 //! use pallet_proposals_engine::{self as engine, ProposalParameters};
 //! use pallet_proposals_engine::{self as engine, ProposalParameters};
 //!
 //!
@@ -134,9 +134,9 @@ use frame_support::traits::{Currency, Get};
 use frame_support::{
 use frame_support::{
     decl_error, decl_event, decl_module, decl_storage, ensure, print, Parameter, StorageDoubleMap,
     decl_error, decl_event, decl_module, decl_storage, ensure, print, Parameter, StorageDoubleMap,
 };
 };
+use frame_system::{ensure_root, RawOrigin};
 use sp_arithmetic::traits::Zero;
 use sp_arithmetic::traits::Zero;
 use sp_std::vec::Vec;
 use sp_std::vec::Vec;
-use system::{ensure_root, RawOrigin};
 
 
 use common::origin::ActorOriginValidator;
 use common::origin::ActorOriginValidator;
 
 
@@ -144,10 +144,10 @@ type MemberId<T> = <T as membership::Trait>::MemberId;
 
 
 /// Proposals engine trait.
 /// Proposals engine trait.
 pub trait Trait:
 pub trait Trait:
-    system::Trait + pallet_timestamp::Trait + stake::Trait + membership::Trait
+    frame_system::Trait + pallet_timestamp::Trait + stake::Trait + membership::Trait
 {
 {
     /// Engine event type.
     /// Engine event type.
-    type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
+    type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
 
 
     /// Validates proposer id and origin combination
     /// Validates proposer id and origin combination
     type ProposerOriginValidator: ActorOriginValidator<
     type ProposerOriginValidator: ActorOriginValidator<
@@ -193,8 +193,8 @@ decl_event!(
     where
     where
         <T as Trait>::ProposalId,
         <T as Trait>::ProposalId,
         MemberId = MemberId<T>,
         MemberId = MemberId<T>,
-        <T as system::Trait>::BlockNumber,
-        <T as system::Trait>::AccountId,
+        <T as frame_system::Trait>::BlockNumber,
+        <T as frame_system::Trait>::AccountId,
         <T as stake::Trait>::StakeId,
         <T as stake::Trait>::StakeId,
     {
     {
         /// Emits on proposal creation.
         /// Emits on proposal creation.
@@ -587,9 +587,9 @@ impl<T: Trait> Module<T> {
 }
 }
 
 
 impl<T: Trait> Module<T> {
 impl<T: Trait> Module<T> {
-    // Wrapper-function over system::block_number()
+    // Wrapper-function over System::block_number()
     fn current_block() -> T::BlockNumber {
     fn current_block() -> T::BlockNumber {
-        <system::Module<T>>::block_number()
+        <frame_system::Module<T>>::block_number()
     }
     }
 
 
     // Enumerates through active proposals. Tally Voting results.
     // Enumerates through active proposals. Tally Voting results.
@@ -819,28 +819,28 @@ impl<T: Trait> Module<T> {
 // Simplification of the 'FinalizedProposalData' type
 // Simplification of the 'FinalizedProposalData' type
 type FinalizedProposal<T> = FinalizedProposalData<
 type FinalizedProposal<T> = FinalizedProposalData<
     <T as Trait>::ProposalId,
     <T as Trait>::ProposalId,
-    <T as system::Trait>::BlockNumber,
+    <T as frame_system::Trait>::BlockNumber,
     MemberId<T>,
     MemberId<T>,
     types::BalanceOf<T>,
     types::BalanceOf<T>,
     <T as stake::Trait>::StakeId,
     <T as stake::Trait>::StakeId,
-    <T as system::Trait>::AccountId,
+    <T as frame_system::Trait>::AccountId,
 >;
 >;
 
 
 // Simplification of the 'ApprovedProposalData' type
 // Simplification of the 'ApprovedProposalData' type
 type ApprovedProposal<T> = ApprovedProposalData<
 type ApprovedProposal<T> = ApprovedProposalData<
     <T as Trait>::ProposalId,
     <T as Trait>::ProposalId,
-    <T as system::Trait>::BlockNumber,
+    <T as frame_system::Trait>::BlockNumber,
     MemberId<T>,
     MemberId<T>,
     types::BalanceOf<T>,
     types::BalanceOf<T>,
     <T as stake::Trait>::StakeId,
     <T as stake::Trait>::StakeId,
-    <T as system::Trait>::AccountId,
+    <T as frame_system::Trait>::AccountId,
 >;
 >;
 
 
 // Simplification of the 'Proposal' type
 // Simplification of the 'Proposal' type
 type ProposalOf<T> = Proposal<
 type ProposalOf<T> = Proposal<
-    <T as system::Trait>::BlockNumber,
+    <T as frame_system::Trait>::BlockNumber,
     MemberId<T>,
     MemberId<T>,
     types::BalanceOf<T>,
     types::BalanceOf<T>,
     <T as stake::Trait>::StakeId,
     <T as stake::Trait>::StakeId,
-    <T as system::Trait>::AccountId,
+    <T as frame_system::Trait>::AccountId,
 >;
 >;

+ 11 - 7
runtime-modules/proposals/engine/src/tests/mock/mod.rs

@@ -9,13 +9,13 @@
 #![cfg(test)]
 #![cfg(test)]
 
 
 use frame_support::{impl_outer_event, impl_outer_origin, parameter_types};
 use frame_support::{impl_outer_event, impl_outer_origin, parameter_types};
+pub use frame_system;
 use sp_core::H256;
 use sp_core::H256;
 use sp_runtime::{
 use sp_runtime::{
     testing::Header,
     testing::Header,
     traits::{BlakeTwo256, IdentityLookup},
     traits::{BlakeTwo256, IdentityLookup},
     Perbill,
     Perbill,
 };
 };
-pub use system;
 
 
 mod balance_manager;
 mod balance_manager;
 pub(crate) mod proposals;
 pub(crate) mod proposals;
@@ -46,7 +46,7 @@ impl_outer_event! {
         balances<T>,
         balances<T>,
         engine<T>,
         engine<T>,
         membership_mod<T>,
         membership_mod<T>,
-        system<T>,
+        frame_system<T>,
     }
     }
 }
 }
 
 
@@ -60,6 +60,8 @@ impl balances::Trait for Test {
     type Event = TestEvent;
     type Event = TestEvent;
     type ExistentialDeposit = ExistentialDeposit;
     type ExistentialDeposit = ExistentialDeposit;
     type AccountStore = System;
     type AccountStore = System;
+    type WeightInfo = ();
+    type MaxLocks = ();
 }
 }
 
 
 impl common::currency::GovernanceCurrency for Test {
 impl common::currency::GovernanceCurrency for Test {
@@ -115,7 +117,7 @@ impl Default for proposals::Call<Test> {
 
 
 impl common::origin::ActorOriginValidator<Origin, u64, u64> for () {
 impl common::origin::ActorOriginValidator<Origin, u64, u64> for () {
     fn ensure_actor_origin(origin: Origin, _account_id: u64) -> Result<u64, &'static str> {
     fn ensure_actor_origin(origin: Origin, _account_id: u64) -> Result<u64, &'static str> {
-        let signed_account_id = system::ensure_signed(origin)?;
+        let signed_account_id = frame_system::ensure_signed(origin)?;
 
 
         Ok(signed_account_id)
         Ok(signed_account_id)
     }
     }
@@ -138,7 +140,7 @@ parameter_types! {
     pub const StakePoolId: [u8; 8] = *b"joystake";
     pub const StakePoolId: [u8; 8] = *b"joystake";
 }
 }
 
 
-impl system::Trait for Test {
+impl frame_system::Trait for Test {
     type BaseCallFilter = ();
     type BaseCallFilter = ();
     type Origin = Origin;
     type Origin = Origin;
     type Call = ();
     type Call = ();
@@ -159,20 +161,22 @@ impl system::Trait for Test {
     type MaximumBlockLength = MaximumBlockLength;
     type MaximumBlockLength = MaximumBlockLength;
     type AvailableBlockRatio = AvailableBlockRatio;
     type AvailableBlockRatio = AvailableBlockRatio;
     type Version = ();
     type Version = ();
-    type ModuleToIndex = ();
+    type PalletInfo = ();
     type AccountData = balances::AccountData<u64>;
     type AccountData = balances::AccountData<u64>;
     type OnNewAccount = ();
     type OnNewAccount = ();
     type OnKilledAccount = ();
     type OnKilledAccount = ();
+    type SystemWeightInfo = ();
 }
 }
 
 
 impl pallet_timestamp::Trait for Test {
 impl pallet_timestamp::Trait for Test {
     type Moment = u64;
     type Moment = u64;
     type OnTimestampSet = ();
     type OnTimestampSet = ();
     type MinimumPeriod = MinimumPeriod;
     type MinimumPeriod = MinimumPeriod;
+    type WeightInfo = ();
 }
 }
 
 
 pub fn initial_test_ext() -> sp_io::TestExternalities {
 pub fn initial_test_ext() -> sp_io::TestExternalities {
-    let t = system::GenesisConfig::default()
+    let t = frame_system::GenesisConfig::default()
         .build_storage::<Test>()
         .build_storage::<Test>()
         .unwrap();
         .unwrap();
 
 
@@ -180,5 +184,5 @@ pub fn initial_test_ext() -> sp_io::TestExternalities {
 }
 }
 
 
 pub type ProposalsEngine = crate::Module<Test>;
 pub type ProposalsEngine = crate::Module<Test>;
-pub type System = system::Module<Test>;
+pub type System = frame_system::Module<Test>;
 pub type Balances = balances::Module<Test>;
 pub type Balances = balances::Module<Test>;

+ 1 - 1
runtime-modules/proposals/engine/src/tests/mock/proposals.rs

@@ -2,7 +2,7 @@
 
 
 use frame_support::decl_module;
 use frame_support::decl_module;
 use sp_std::vec::Vec;
 use sp_std::vec::Vec;
-pub trait Trait: system::Trait {}
+pub trait Trait: frame_system::Trait {}
 
 
 decl_module! {
 decl_module! {
     pub struct Module<T: Trait> for enum Call where origin: T::Origin {
     pub struct Module<T: Trait> for enum Call where origin: T::Origin {

+ 9 - 4
runtime-modules/proposals/engine/src/tests/mod.rs

@@ -7,9 +7,9 @@ use codec::Encode;
 use frame_support::dispatch::DispatchResult;
 use frame_support::dispatch::DispatchResult;
 use frame_support::traits::{Currency, OnFinalize, OnInitialize};
 use frame_support::traits::{Currency, OnFinalize, OnInitialize};
 use frame_support::{StorageDoubleMap, StorageMap, StorageValue};
 use frame_support::{StorageDoubleMap, StorageMap, StorageValue};
+use frame_system::RawOrigin;
+use frame_system::{EventRecord, Phase};
 use sp_std::rc::Rc;
 use sp_std::rc::Rc;
-use system::RawOrigin;
-use system::{EventRecord, Phase};
 
 
 pub(crate) fn increase_total_balance_issuance_using_account_id(account_id: u64, balance: u64) {
 pub(crate) fn increase_total_balance_issuance_using_account_id(account_id: u64, balance: u64) {
     let initial_balance = Balances::total_issuance();
     let initial_balance = Balances::total_issuance();
@@ -240,7 +240,7 @@ impl VoteGenerator {
         }
         }
 
 
         ProposalsEngine::vote(
         ProposalsEngine::vote(
-            system::RawOrigin::Signed(self.current_account_id).into(),
+            frame_system::RawOrigin::Signed(self.current_account_id).into(),
             self.current_voter_id,
             self.current_voter_id,
             self.proposal_id,
             self.proposal_id,
             vote_kind,
             vote_kind,
@@ -305,7 +305,12 @@ fn vote_succeeds() {
 fn vote_fails_with_insufficient_rights() {
 fn vote_fails_with_insufficient_rights() {
     initial_test_ext().execute_with(|| {
     initial_test_ext().execute_with(|| {
         assert_eq!(
         assert_eq!(
-            ProposalsEngine::vote(system::RawOrigin::None.into(), 1, 1, VoteKind::Approve),
+            ProposalsEngine::vote(
+                frame_system::RawOrigin::None.into(),
+                1,
+                1,
+                VoteKind::Approve
+            ),
             Err(DispatchError::Other("Bad origin"))
             Err(DispatchError::Other("Bad origin"))
         );
         );
     });
     });

+ 5 - 4
runtime-modules/proposals/engine/src/types/mod.rs

@@ -308,7 +308,7 @@ pub trait ProposalExecutable {
 }
 }
 
 
 /// Proposal code binary converter
 /// Proposal code binary converter
-pub trait ProposalCodeDecoder<T: system::Trait> {
+pub trait ProposalCodeDecoder<T: frame_system::Trait> {
     /// Converts proposal code binary to executable representation
     /// Converts proposal code binary to executable representation
     fn decode_proposal(
     fn decode_proposal(
         proposal_type: u32,
         proposal_type: u32,
@@ -318,11 +318,12 @@ pub trait ProposalCodeDecoder<T: system::Trait> {
 
 
 /// Balance alias
 /// Balance alias
 pub type BalanceOf<T> =
 pub type BalanceOf<T> =
-    <<T as stake::Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
+    <<T as stake::Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
 
 
 /// Balance alias for staking
 /// Balance alias for staking
-pub type NegativeImbalance<T> =
-    <<T as stake::Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;
+pub type NegativeImbalance<T> = <<T as stake::Trait>::Currency as Currency<
+    <T as frame_system::Trait>::AccountId,
+>>::NegativeImbalance;
 
 
 /// Balance type of runtime
 /// Balance type of runtime
 pub type CurrencyOf<T> = <T as stake::Trait>::Currency;
 pub type CurrencyOf<T> = <T as stake::Trait>::Currency;

+ 10 - 10
runtime-modules/recurring-reward/Cargo.toml

@@ -1,21 +1,21 @@
 [package]
 [package]
 name = 'pallet-recurring-reward'
 name = 'pallet-recurring-reward'
-version = '3.0.0'
+version = '3.1.0'
 authors = ['Joystream contributors']
 authors = ['Joystream contributors']
 edition = '2018'
 edition = '2018'
 
 
 [dependencies]
 [dependencies]
-codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
-sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+codec = { package = 'parity-scale-codec', version = '1.3.4', default-features = false, features = ['derive'] }
+sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 minting = { package = 'pallet-token-mint', default-features = false, path = '../token-minting'}
 minting = { package = 'pallet-token-mint', default-features = false, path = '../token-minting'}
 
 
 [dev-dependencies]
 [dev-dependencies]
-sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 
 
 [features]
 [features]
 default = ['std']
 default = ['std']
@@ -24,6 +24,6 @@ std = [
 	'sp-arithmetic/std',
 	'sp-arithmetic/std',
 	'sp-runtime/std',
 	'sp-runtime/std',
 	'frame-support/std',
 	'frame-support/std',
-	'system/std',
+	'frame-system/std',
 	'minting/std',
 	'minting/std',
 ]
 ]

+ 3 - 3
runtime-modules/recurring-reward/src/lib.rs

@@ -19,7 +19,7 @@ use minting::BalanceOf;
 mod mock;
 mod mock;
 mod tests;
 mod tests;
 
 
-pub trait Trait: system::Trait + minting::Trait {
+pub trait Trait: frame_system::Trait + minting::Trait {
     type PayoutStatusHandler: PayoutStatusHandler<Self>;
     type PayoutStatusHandler: PayoutStatusHandler<Self>;
 
 
     /// Type of identifier for recipients.
     /// Type of identifier for recipients.
@@ -199,7 +199,7 @@ impl<T: Trait> Module<T> {
             RewardsError::RecipientNotFound
             RewardsError::RecipientNotFound
         );
         );
         ensure!(
         ensure!(
-            next_payment_at_block > <system::Module<T>>::block_number(),
+            next_payment_at_block > <frame_system::Module<T>>::block_number(),
             RewardsError::NextPaymentNotInFuture
             RewardsError::NextPaymentNotInFuture
         );
         );
 
 
@@ -300,7 +300,7 @@ impl<T: Trait> Module<T> {
         if let Some(next_payout_at_block) = new_next_payment_at {
         if let Some(next_payout_at_block) = new_next_payment_at {
             if let Some(blocknumber) = next_payout_at_block {
             if let Some(blocknumber) = next_payout_at_block {
                 ensure!(
                 ensure!(
-                    blocknumber > <system::Module<T>>::block_number(),
+                    blocknumber > <frame_system::Module<T>>::block_number(),
                     RewardsError::NextPaymentNotInFuture
                     RewardsError::NextPaymentNotInFuture
                 );
                 );
             }
             }

+ 7 - 4
runtime-modules/recurring-reward/src/mock/mod.rs

@@ -30,7 +30,7 @@ parameter_types! {
     pub const MinimumPeriod: u64 = 5;
     pub const MinimumPeriod: u64 = 5;
 }
 }
 
 
-impl system::Trait for Test {
+impl frame_system::Trait for Test {
     type BaseCallFilter = ();
     type BaseCallFilter = ();
     type Origin = Origin;
     type Origin = Origin;
     type Call = ();
     type Call = ();
@@ -51,10 +51,11 @@ impl system::Trait for Test {
     type MaximumBlockLength = MaximumBlockLength;
     type MaximumBlockLength = MaximumBlockLength;
     type AvailableBlockRatio = AvailableBlockRatio;
     type AvailableBlockRatio = AvailableBlockRatio;
     type Version = ();
     type Version = ();
-    type ModuleToIndex = ();
+    type PalletInfo = ();
     type AccountData = balances::AccountData<u64>;
     type AccountData = balances::AccountData<u64>;
     type OnNewAccount = ();
     type OnNewAccount = ();
     type OnKilledAccount = ();
     type OnKilledAccount = ();
+    type SystemWeightInfo = ();
 }
 }
 
 
 parameter_types! {
 parameter_types! {
@@ -67,6 +68,8 @@ impl balances::Trait for Test {
     type Event = ();
     type Event = ();
     type ExistentialDeposit = ExistentialDeposit;
     type ExistentialDeposit = ExistentialDeposit;
     type AccountStore = System;
     type AccountStore = System;
+    type WeightInfo = ();
+    type MaxLocks = ();
 }
 }
 
 
 impl Trait for Test {
 impl Trait for Test {
@@ -83,14 +86,14 @@ impl minting::Trait for Test {
 pub fn build_test_externalities() -> sp_io::TestExternalities {
 pub fn build_test_externalities() -> sp_io::TestExternalities {
     MockStatusHandler::reset();
     MockStatusHandler::reset();
 
 
-    let t = system::GenesisConfig::default()
+    let t = frame_system::GenesisConfig::default()
         .build_storage::<Test>()
         .build_storage::<Test>()
         .unwrap();
         .unwrap();
 
 
     t.into()
     t.into()
 }
 }
 
 
-pub type System = system::Module<Test>;
+pub type System = frame_system::Module<Test>;
 pub type Balances = balances::Module<Test>;
 pub type Balances = balances::Module<Test>;
 pub type Rewards = Module<Test>;
 pub type Rewards = Module<Test>;
 pub type Minting = minting::Module<Test>;
 pub type Minting = minting::Module<Test>;

+ 11 - 11
runtime-modules/service-discovery/Cargo.toml

@@ -1,23 +1,23 @@
 [package]
 [package]
 name = 'pallet-service-discovery'
 name = 'pallet-service-discovery'
-version = '3.0.0'
+version = '3.1.0'
 authors = ['Joystream contributors']
 authors = ['Joystream contributors']
 edition = '2018'
 edition = '2018'
 
 
 [dependencies]
 [dependencies]
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
-codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
-sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+codec = { package = 'parity-scale-codec', version = '1.3.4', default-features = false, features = ['derive'] }
+sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 working-group = { package = 'pallet-working-group', default-features = false, path = '../working-group'}
 working-group = { package = 'pallet-working-group', default-features = false, path = '../working-group'}
 
 
 [dev-dependencies]
 [dev-dependencies]
-sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 membership = { package = 'pallet-membership', default-features = false, path = '../membership'}
 membership = { package = 'pallet-membership', default-features = false, path = '../membership'}
 stake = { package = 'pallet-stake', default-features = false, path = '../stake'}
 stake = { package = 'pallet-stake', default-features = false, path = '../stake'}
 hiring = { package = 'pallet-hiring', default-features = false, path = '../hiring'}
 hiring = { package = 'pallet-hiring', default-features = false, path = '../hiring'}
@@ -32,7 +32,7 @@ std = [
 	'codec/std',
 	'codec/std',
 	'sp-std/std',
 	'sp-std/std',
 	'frame-support/std',
 	'frame-support/std',
-	'system/std',
+	'frame-system/std',
 	'sp-runtime/std',
 	'sp-runtime/std',
 	'working-group/std',
 	'working-group/std',
 ]
 ]

+ 6 - 5
runtime-modules/service-discovery/src/lib.rs

@@ -27,8 +27,9 @@ use codec::{Decode, Encode};
 use serde::{Deserialize, Serialize};
 use serde::{Deserialize, Serialize};
 
 
 use frame_support::{decl_event, decl_module, decl_storage, ensure};
 use frame_support::{decl_event, decl_module, decl_storage, ensure};
+use frame_system::ensure_root;
 use sp_std::vec::Vec;
 use sp_std::vec::Vec;
-use system::ensure_root;
+
 /*
 /*
   Although there is support for ed25519 keys as the IPNS identity key and we could potentially
   Although there is support for ed25519 keys as the IPNS identity key and we could potentially
   reuse the same key for the role account and ipns (and make this discovery module obselete)
   reuse the same key for the role account and ipns (and make this discovery module obselete)
@@ -71,9 +72,9 @@ pub struct ServiceProviderRecord<BlockNumber> {
 }
 }
 
 
 /// The _Service discovery_ main _Trait_.
 /// The _Service discovery_ main _Trait_.
-pub trait Trait: system::Trait + working_group::Trait<StorageWorkingGroupInstance> {
+pub trait Trait: frame_system::Trait + working_group::Trait<StorageWorkingGroupInstance> {
     /// _Service discovery_ event type.
     /// _Service discovery_ event type.
-    type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
+    type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
 }
 }
 
 
 decl_storage! {
 decl_storage! {
@@ -133,7 +134,7 @@ decl_module! {
 
 
             <AccountInfoByStorageProviderId<T>>::insert(storage_provider_id, ServiceProviderRecord {
             <AccountInfoByStorageProviderId<T>>::insert(storage_provider_id, ServiceProviderRecord {
                 identity: id.clone(),
                 identity: id.clone(),
-                expires_at: <system::Module<T>>::block_number() + Self::default_lifetime(),
+                expires_at: <frame_system::Module<T>>::block_number() + Self::default_lifetime(),
             });
             });
 
 
             Self::deposit_event(RawEvent::AccountInfoUpdated(storage_provider_id, id));
             Self::deposit_event(RawEvent::AccountInfoUpdated(storage_provider_id, id));
@@ -183,7 +184,7 @@ impl<T: Trait> Module<T> {
     /// Verifies that account info for the storage provider is still valid.
     /// Verifies that account info for the storage provider is still valid.
     pub fn is_account_info_expired(storage_provider_id: &StorageProviderId<T>) -> bool {
     pub fn is_account_info_expired(storage_provider_id: &StorageProviderId<T>) -> bool {
         !<AccountInfoByStorageProviderId<T>>::contains_key(storage_provider_id)
         !<AccountInfoByStorageProviderId<T>>::contains_key(storage_provider_id)
-            || <system::Module<T>>::block_number()
+            || <frame_system::Module<T>>::block_number()
                 > <AccountInfoByStorageProviderId<T>>::get(storage_provider_id).expires_at
                 > <AccountInfoByStorageProviderId<T>>::get(storage_provider_id).expires_at
     }
     }
 }
 }

+ 9 - 5
runtime-modules/service-discovery/src/mock.rs

@@ -37,7 +37,7 @@ impl_outer_event! {
         balances<T>,
         balances<T>,
         membership_mod<T>,
         membership_mod<T>,
         working_group_mod StorageWorkingGroupInstance <T>,
         working_group_mod StorageWorkingGroupInstance <T>,
-        system<T>,
+        frame_system<T>,
     }
     }
 }
 }
 
 
@@ -54,7 +54,7 @@ parameter_types! {
     pub const ExistentialDeposit: u32 = 0;
     pub const ExistentialDeposit: u32 = 0;
 }
 }
 
 
-impl system::Trait for Test {
+impl frame_system::Trait for Test {
     type BaseCallFilter = ();
     type BaseCallFilter = ();
     type Origin = Origin;
     type Origin = Origin;
     type Call = ();
     type Call = ();
@@ -75,10 +75,11 @@ impl system::Trait for Test {
     type MaximumBlockLength = MaximumBlockLength;
     type MaximumBlockLength = MaximumBlockLength;
     type AvailableBlockRatio = AvailableBlockRatio;
     type AvailableBlockRatio = AvailableBlockRatio;
     type Version = ();
     type Version = ();
-    type ModuleToIndex = ();
+    type PalletInfo = ();
     type AccountData = balances::AccountData<u64>;
     type AccountData = balances::AccountData<u64>;
     type OnNewAccount = ();
     type OnNewAccount = ();
     type OnKilledAccount = ();
     type OnKilledAccount = ();
+    type SystemWeightInfo = ();
 }
 }
 
 
 impl Trait for Test {
 impl Trait for Test {
@@ -123,6 +124,8 @@ impl balances::Trait for Test {
     type Event = MetaEvent;
     type Event = MetaEvent;
     type ExistentialDeposit = ExistentialDeposit;
     type ExistentialDeposit = ExistentialDeposit;
     type AccountStore = System;
     type AccountStore = System;
+    type WeightInfo = ();
+    type MaxLocks = ();
 }
 }
 
 
 impl recurringrewards::Trait for Test {
 impl recurringrewards::Trait for Test {
@@ -144,10 +147,11 @@ impl pallet_timestamp::Trait for Test {
     type Moment = u64;
     type Moment = u64;
     type OnTimestampSet = ();
     type OnTimestampSet = ();
     type MinimumPeriod = MinimumPeriod;
     type MinimumPeriod = MinimumPeriod;
+    type WeightInfo = ();
 }
 }
 
 
 pub fn initial_test_ext() -> sp_io::TestExternalities {
 pub fn initial_test_ext() -> sp_io::TestExternalities {
-    let t = system::GenesisConfig::default()
+    let t = frame_system::GenesisConfig::default()
         .build_storage::<Test>()
         .build_storage::<Test>()
         .unwrap();
         .unwrap();
 
 
@@ -155,7 +159,7 @@ pub fn initial_test_ext() -> sp_io::TestExternalities {
 }
 }
 
 
 pub type Balances = balances::Module<Test>;
 pub type Balances = balances::Module<Test>;
-pub type System = system::Module<Test>;
+pub type System = frame_system::Module<Test>;
 pub type Discovery = Module<Test>;
 pub type Discovery = Module<Test>;
 
 
 pub(crate) fn hire_storage_provider() -> (u64, u64) {
 pub(crate) fn hire_storage_provider() -> (u64, u64) {

+ 4 - 4
runtime-modules/service-discovery/src/tests.rs

@@ -2,7 +2,7 @@
 
 
 use super::mock::*;
 use super::mock::*;
 
 
-use system::{EventRecord, Phase, RawOrigin};
+use frame_system::{EventRecord, Phase, RawOrigin};
 
 
 #[test]
 #[test]
 fn set_ipns_id() {
 fn set_ipns_id() {
@@ -13,7 +13,7 @@ fn set_ipns_id() {
         let (storage_provider_account_id, storage_provider_id) = hire_storage_provider();
         let (storage_provider_account_id, storage_provider_id) = hire_storage_provider();
 
 
         let identity = "alice".as_bytes().to_vec();
         let identity = "alice".as_bytes().to_vec();
-        let ttl = <Test as system::Trait>::BlockNumber::from(DEFAULT_LIFETIME);
+        let ttl = <Test as frame_system::Trait>::BlockNumber::from(DEFAULT_LIFETIME);
         assert!(Discovery::set_ipns_id(
         assert!(Discovery::set_ipns_id(
             Origin::signed(storage_provider_account_id),
             Origin::signed(storage_provider_account_id),
             storage_provider_id,
             storage_provider_id,
@@ -137,7 +137,7 @@ fn is_account_info_expired() {
 #[test]
 #[test]
 fn set_default_lifetime() {
 fn set_default_lifetime() {
     initial_test_ext().execute_with(|| {
     initial_test_ext().execute_with(|| {
-        let lifetime = <Test as system::Trait>::BlockNumber::from(MINIMUM_LIFETIME + 2000);
+        let lifetime = <Test as frame_system::Trait>::BlockNumber::from(MINIMUM_LIFETIME + 2000);
         // privileged method should fail if not from root origin
         // privileged method should fail if not from root origin
         assert!(
         assert!(
             Discovery::set_default_lifetime(Origin::signed(1), lifetime).is_err(),
             Discovery::set_default_lifetime(Origin::signed(1), lifetime).is_err(),
@@ -151,7 +151,7 @@ fn set_default_lifetime() {
 
 
         // cannot set default lifetime to less than minimum
         // cannot set default lifetime to less than minimum
         let less_than_min_lifetime =
         let less_than_min_lifetime =
-            <Test as system::Trait>::BlockNumber::from(MINIMUM_LIFETIME - 1);
+            <Test as frame_system::Trait>::BlockNumber::from(MINIMUM_LIFETIME - 1);
         assert!(
         assert!(
             Discovery::set_default_lifetime(RawOrigin::Root.into(), less_than_min_lifetime)
             Discovery::set_default_lifetime(RawOrigin::Root.into(), less_than_min_lifetime)
                 .is_err(),
                 .is_err(),

+ 12 - 12
runtime-modules/stake/Cargo.toml

@@ -1,22 +1,22 @@
 [package]
 [package]
 name = 'pallet-stake'
 name = 'pallet-stake'
-version = '3.0.0'
+version = '3.1.0'
 authors = ['Joystream contributors']
 authors = ['Joystream contributors']
 edition = '2018'
 edition = '2018'
 
 
 [dependencies]
 [dependencies]
-codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
-sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+codec = { package = 'parity-scale-codec', version = '1.3.4', default-features = false, features = ['derive'] }
+sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 
 
 [dev-dependencies]
 [dev-dependencies]
-sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 
 
 [features]
 [features]
 default = ['std']
 default = ['std']
@@ -24,7 +24,7 @@ std = [
 	'codec/std',
 	'codec/std',
 	'sp-std/std',
 	'sp-std/std',
 	'frame-support/std',
 	'frame-support/std',
-	'system/std',
+	'frame-system/std',
 	'sp-arithmetic/std',
 	'sp-arithmetic/std',
 	'sp-runtime/std',
 	'sp-runtime/std',
 ]
 ]

+ 10 - 6
runtime-modules/stake/src/lib.rs

@@ -18,12 +18,12 @@ mod mock;
 mod tests;
 mod tests;
 
 
 pub type BalanceOf<T> =
 pub type BalanceOf<T> =
-    <<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
+    <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
 
 
 pub type NegativeImbalance<T> =
 pub type NegativeImbalance<T> =
-    <<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;
+    <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
 
 
-pub trait Trait: system::Trait + Sized {
+pub trait Trait: frame_system::Trait + Sized {
     /// The currency that is managed by the module
     /// The currency that is managed by the module
     type Currency: Currency<Self::AccountId>;
     type Currency: Currency<Self::AccountId>;
 
 
@@ -744,7 +744,10 @@ impl<T: Trait> Module<T> {
         let stake_id = Self::stakes_created();
         let stake_id = Self::stakes_created();
         <StakesCreated<T>>::put(stake_id + One::one());
         <StakesCreated<T>>::put(stake_id + One::one());
 
 
-        <Stakes<T>>::insert(&stake_id, Stake::new(<system::Module<T>>::block_number()));
+        <Stakes<T>>::insert(
+            &stake_id,
+            Stake::new(<frame_system::Module<T>>::block_number()),
+        );
 
 
         stake_id
         stake_id
     }
     }
@@ -1036,7 +1039,7 @@ impl<T: Trait> Module<T> {
         let slash_id = stake.initiate_slashing(
         let slash_id = stake.initiate_slashing(
             slash_amount,
             slash_amount,
             slash_period,
             slash_period,
-            <system::Module<T>>::block_number(),
+            <frame_system::Module<T>>::block_number(),
         )?;
         )?;
 
 
         <Stakes<T>>::insert(stake_id, stake);
         <Stakes<T>>::insert(stake_id, stake);
@@ -1092,7 +1095,8 @@ impl<T: Trait> Module<T> {
         let mut stake = ensure_stake_exists!(T, stake_id, StakeActionError::StakeNotFound)?;
         let mut stake = ensure_stake_exists!(T, stake_id, StakeActionError::StakeNotFound)?;
 
 
         if let Some(unstaking_period) = unstaking_period {
         if let Some(unstaking_period) = unstaking_period {
-            stake.initiate_unstaking(unstaking_period, <system::Module<T>>::block_number())?;
+            stake
+                .initiate_unstaking(unstaking_period, <frame_system::Module<T>>::block_number())?;
             <Stakes<T>>::insert(stake_id, stake);
             <Stakes<T>>::insert(stake_id, stake);
         } else {
         } else {
             let staked_amount = stake.unstake()?;
             let staked_amount = stake.unstake()?;

+ 9 - 5
runtime-modules/stake/src/mock.rs

@@ -25,7 +25,7 @@ parameter_types! {
     pub const AvailableBlockRatio: Perbill = Perbill::one();
     pub const AvailableBlockRatio: Perbill = Perbill::one();
 }
 }
 
 
-impl system::Trait for Test {
+impl frame_system::Trait for Test {
     type BaseCallFilter = ();
     type BaseCallFilter = ();
     type Origin = Origin;
     type Origin = Origin;
     type Call = ();
     type Call = ();
@@ -46,15 +46,17 @@ impl system::Trait for Test {
     type MaximumBlockLength = MaximumBlockLength;
     type MaximumBlockLength = MaximumBlockLength;
     type AvailableBlockRatio = AvailableBlockRatio;
     type AvailableBlockRatio = AvailableBlockRatio;
     type Version = ();
     type Version = ();
-    type ModuleToIndex = ();
+    type PalletInfo = ();
     type AccountData = balances::AccountData<u64>;
     type AccountData = balances::AccountData<u64>;
     type OnNewAccount = ();
     type OnNewAccount = ();
     type OnKilledAccount = ();
     type OnKilledAccount = ();
+    type SystemWeightInfo = ();
 }
 }
 
 
 parameter_types! {
 parameter_types! {
     pub const ExistentialDeposit: u32 = 500;
     pub const ExistentialDeposit: u32 = 500;
     pub const StakePoolId: [u8; 8] = *b"joystake";
     pub const StakePoolId: [u8; 8] = *b"joystake";
+    pub const MaxLocks: u32 = 50;
 }
 }
 
 
 impl balances::Trait for Test {
 impl balances::Trait for Test {
@@ -63,6 +65,8 @@ impl balances::Trait for Test {
     type Event = ();
     type Event = ();
     type ExistentialDeposit = ExistentialDeposit;
     type ExistentialDeposit = ExistentialDeposit;
     type AccountStore = System;
     type AccountStore = System;
+    type WeightInfo = ();
+    type MaxLocks = MaxLocks;
 }
 }
 
 
 impl Trait for Test {
 impl Trait for Test {
@@ -74,14 +78,14 @@ impl Trait for Test {
 }
 }
 
 
 pub fn build_test_externalities() -> sp_io::TestExternalities {
 pub fn build_test_externalities() -> sp_io::TestExternalities {
-    let t = system::GenesisConfig::default()
+    let t = frame_system::GenesisConfig::default()
         .build_storage::<Test>()
         .build_storage::<Test>()
         .unwrap();
         .unwrap();
 
 
     t.into()
     t.into()
 }
 }
 
 
-pub type System = system::Module<Test>;
+pub type System = frame_system::Module<Test>;
 pub type Balances = balances::Module<Test>;
 pub type Balances = balances::Module<Test>;
 pub type StakePool = Module<Test>;
 pub type StakePool = Module<Test>;
 
 
@@ -90,6 +94,6 @@ pub mod fixtures {
     use super::*;
     use super::*;
     pub type OngoingSlashes = BTreeMap<
     pub type OngoingSlashes = BTreeMap<
         <Test as Trait>::SlashId,
         <Test as Trait>::SlashId,
-        Slash<<Test as system::Trait>::BlockNumber, BalanceOf<Test>>,
+        Slash<<Test as frame_system::Trait>::BlockNumber, BalanceOf<Test>>,
     >;
     >;
 }
 }

+ 12 - 12
runtime-modules/storage/Cargo.toml

@@ -1,26 +1,26 @@
 [package]
 [package]
 name = 'pallet-storage'
 name = 'pallet-storage'
-version = '3.0.0'
+version = '3.1.0'
 authors = ['Joystream contributors']
 authors = ['Joystream contributors']
 edition = '2018'
 edition = '2018'
 
 
 [dependencies]
 [dependencies]
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
-codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
-sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+codec = { package = 'parity-scale-codec', version = '1.3.4', default-features = false, features = ['derive'] }
+sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 membership = { package = 'pallet-membership', default-features = false, path = '../membership'}
 membership = { package = 'pallet-membership', default-features = false, path = '../membership'}
-pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 working-group = { package = 'pallet-working-group', default-features = false, path = '../working-group'}
 working-group = { package = 'pallet-working-group', default-features = false, path = '../working-group'}
 common = { package = 'pallet-common', default-features = false, path = '../common'}
 common = { package = 'pallet-common', default-features = false, path = '../common'}
 
 
 [dev-dependencies]
 [dev-dependencies]
-sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 stake = { package = 'pallet-stake', default-features = false, path = '../stake'}
 stake = { package = 'pallet-stake', default-features = false, path = '../stake'}
 hiring = { package = 'pallet-hiring', default-features = false, path = '../hiring'}
 hiring = { package = 'pallet-hiring', default-features = false, path = '../hiring'}
 minting = { package = 'pallet-token-mint', default-features = false, path = '../token-minting'}
 minting = { package = 'pallet-token-mint', default-features = false, path = '../token-minting'}
@@ -33,7 +33,7 @@ std = [
 	'codec/std',
 	'codec/std',
 	'sp-std/std',
 	'sp-std/std',
 	'frame-support/std',
 	'frame-support/std',
-	'system/std',
+	'frame-system/std',
 	'sp-arithmetic/std',
 	'sp-arithmetic/std',
 	'sp-runtime/std',
 	'sp-runtime/std',
 	'membership/std',
 	'membership/std',

+ 4 - 4
runtime-modules/storage/src/data_directory.rs

@@ -25,10 +25,10 @@ use codec::{Decode, Encode};
 use frame_support::dispatch::DispatchResult;
 use frame_support::dispatch::DispatchResult;
 use frame_support::traits::Get;
 use frame_support::traits::Get;
 use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure, Parameter};
 use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure, Parameter};
+use frame_system::ensure_root;
 use sp_runtime::traits::{MaybeSerialize, Member};
 use sp_runtime::traits::{MaybeSerialize, Member};
 use sp_std::collections::btree_map::BTreeMap;
 use sp_std::collections::btree_map::BTreeMap;
 use sp_std::vec::Vec;
 use sp_std::vec::Vec;
-use system::ensure_root;
 
 
 #[cfg(feature = "std")]
 #[cfg(feature = "std")]
 use serde::{Deserialize, Serialize};
 use serde::{Deserialize, Serialize};
@@ -43,13 +43,13 @@ use crate::{MemberId, StorageProviderId, StorageWorkingGroup, StorageWorkingGrou
 /// The _Data directory_ main _Trait_.
 /// The _Data directory_ main _Trait_.
 pub trait Trait:
 pub trait Trait:
     pallet_timestamp::Trait
     pallet_timestamp::Trait
-    + system::Trait
+    + frame_system::Trait
     + data_object_type_registry::Trait
     + data_object_type_registry::Trait
     + membership::Trait
     + membership::Trait
     + working_group::Trait<StorageWorkingGroupInstance>
     + working_group::Trait<StorageWorkingGroupInstance>
 {
 {
     /// _Data directory_ event type.
     /// _Data directory_ event type.
-    type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
+    type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
 
 
     /// Content id.
     /// Content id.
     type ContentId: Parameter + Member + MaybeSerialize + Copy + Ord + Default;
     type ContentId: Parameter + Member + MaybeSerialize + Copy + Ord + Default;
@@ -112,7 +112,7 @@ impl Default for LiaisonJudgement {
 /// Alias for DataObjectInternal
 /// Alias for DataObjectInternal
 pub type DataObject<T> = DataObjectInternal<
 pub type DataObject<T> = DataObjectInternal<
     MemberId<T>,
     MemberId<T>,
-    <T as system::Trait>::BlockNumber,
+    <T as frame_system::Trait>::BlockNumber,
     <T as pallet_timestamp::Trait>::Moment,
     <T as pallet_timestamp::Trait>::Moment,
     <T as data_object_type_registry::Trait>::DataObjectTypeId,
     <T as data_object_type_registry::Trait>::DataObjectTypeId,
     StorageProviderId<T>,
     StorageProviderId<T>,

+ 2 - 2
runtime-modules/storage/src/data_object_storage_registry.rs

@@ -37,12 +37,12 @@ const DEFAULT_FIRST_RELATIONSHIP_ID: u8 = 1;
 /// The _Data object storage registry_ main _Trait_.
 /// The _Data object storage registry_ main _Trait_.
 pub trait Trait:
 pub trait Trait:
     pallet_timestamp::Trait
     pallet_timestamp::Trait
-    + system::Trait
+    + frame_system::Trait
     + data_directory::Trait
     + data_directory::Trait
     + working_group::Trait<StorageWorkingGroupInstance>
     + working_group::Trait<StorageWorkingGroupInstance>
 {
 {
     /// _Data object storage registry_ event type.
     /// _Data object storage registry_ event type.
-    type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
+    type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
 
 
     /// Type for data object storage relationship id
     /// Type for data object storage relationship id
     type DataObjectStorageRelationshipId: Parameter
     type DataObjectStorageRelationshipId: Parameter

+ 2 - 2
runtime-modules/storage/src/data_object_type_registry.rs

@@ -36,9 +36,9 @@ const DEFAULT_TYPE_DESCRIPTION: &str = "Default data object type for audio and v
 const DEFAULT_FIRST_DATA_OBJECT_TYPE_ID: u8 = 1;
 const DEFAULT_FIRST_DATA_OBJECT_TYPE_ID: u8 = 1;
 
 
 /// The _Data object type registry_ main _Trait_.
 /// The _Data object type registry_ main _Trait_.
-pub trait Trait: system::Trait + working_group::Trait<StorageWorkingGroupInstance> {
+pub trait Trait: frame_system::Trait + working_group::Trait<StorageWorkingGroupInstance> {
     /// _Data object type registry_ event type.
     /// _Data object type registry_ event type.
-    type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
+    type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
 
 
     /// _Data object type id_ type
     /// _Data object type id_ type
     type DataObjectTypeId: Parameter
     type DataObjectTypeId: Parameter

+ 2 - 2
runtime-modules/storage/src/tests/data_directory.rs

@@ -1,8 +1,8 @@
 #![cfg(test)]
 #![cfg(test)]
 
 
 use frame_support::dispatch::DispatchError;
 use frame_support::dispatch::DispatchError;
+use frame_system::RawOrigin;
 use sp_std::collections::btree_map::BTreeMap;
 use sp_std::collections::btree_map::BTreeMap;
-use system::RawOrigin;
 
 
 use super::mock::*;
 use super::mock::*;
 
 
@@ -197,7 +197,7 @@ fn reject_content_as_liaison() {
 fn data_object_injection_works() {
 fn data_object_injection_works() {
     with_default_mock_builder(|| {
     with_default_mock_builder(|| {
         // No objects in directory before injection
         // No objects in directory before injection
-        assert_eq!(TestDataDirectory::known_content_ids(), vec![]);
+        assert_eq!(TestDataDirectory::known_content_ids(), Vec::<u64>::new());
 
 
         // new objects to inject into the directory
         // new objects to inject into the directory
         let mut objects = BTreeMap::new();
         let mut objects = BTreeMap::new();

+ 1 - 1
runtime-modules/storage/src/tests/data_object_type_registry.rs

@@ -1,7 +1,7 @@
 #![cfg(test)]
 #![cfg(test)]
 
 
 use frame_support::{StorageMap, StorageValue};
 use frame_support::{StorageMap, StorageValue};
-use system::{EventRecord, Phase, RawOrigin};
+use frame_system::{EventRecord, Phase, RawOrigin};
 
 
 use super::mock::*;
 use super::mock::*;
 
 

+ 10 - 6
runtime-modules/storage/src/tests/mock.rs

@@ -38,7 +38,7 @@ impl_outer_event! {
         balances<T>,
         balances<T>,
         members<T>,
         members<T>,
         working_group_mod StorageWorkingGroupInstance <T>,
         working_group_mod StorageWorkingGroupInstance <T>,
-        system<T>,
+        frame_system<T>,
     }
     }
 }
 }
 
 
@@ -96,7 +96,7 @@ parameter_types! {
     pub const MaxObjectsPerInjection: u32 = 5;
     pub const MaxObjectsPerInjection: u32 = 5;
 }
 }
 
 
-impl system::Trait for Test {
+impl frame_system::Trait for Test {
     type BaseCallFilter = ();
     type BaseCallFilter = ();
     type Origin = Origin;
     type Origin = Origin;
     type Call = ();
     type Call = ();
@@ -117,16 +117,18 @@ impl system::Trait for Test {
     type MaximumBlockLength = MaximumBlockLength;
     type MaximumBlockLength = MaximumBlockLength;
     type AvailableBlockRatio = AvailableBlockRatio;
     type AvailableBlockRatio = AvailableBlockRatio;
     type Version = ();
     type Version = ();
-    type ModuleToIndex = ();
+    type PalletInfo = ();
     type AccountData = balances::AccountData<u64>;
     type AccountData = balances::AccountData<u64>;
     type OnNewAccount = ();
     type OnNewAccount = ();
     type OnKilledAccount = ();
     type OnKilledAccount = ();
+    type SystemWeightInfo = ();
 }
 }
 
 
 impl pallet_timestamp::Trait for Test {
 impl pallet_timestamp::Trait for Test {
     type Moment = u64;
     type Moment = u64;
     type OnTimestampSet = ();
     type OnTimestampSet = ();
     type MinimumPeriod = MinimumPeriod;
     type MinimumPeriod = MinimumPeriod;
+    type WeightInfo = ();
 }
 }
 
 
 parameter_types! {
 parameter_types! {
@@ -140,6 +142,8 @@ impl balances::Trait for Test {
     type Event = MetaEvent;
     type Event = MetaEvent;
     type ExistentialDeposit = ExistentialDeposit;
     type ExistentialDeposit = ExistentialDeposit;
     type AccountStore = System;
     type AccountStore = System;
+    type WeightInfo = ();
+    type MaxLocks = ();
 }
 }
 
 
 impl GovernanceCurrency for Test {
 impl GovernanceCurrency for Test {
@@ -177,7 +181,7 @@ impl crate::data_directory::StorageProviderHelper<Test> for () {
 
 
 impl common::origin::ActorOriginValidator<Origin, u64, u64> for () {
 impl common::origin::ActorOriginValidator<Origin, u64, u64> for () {
     fn ensure_actor_origin(origin: Origin, _account_id: u64) -> Result<u64, &'static str> {
     fn ensure_actor_origin(origin: Origin, _account_id: u64) -> Result<u64, &'static str> {
-        let signed_account_id = system::ensure_signed(origin)?;
+        let signed_account_id = frame_system::ensure_signed(origin)?;
 
 
         Ok(signed_account_id)
         Ok(signed_account_id)
     }
     }
@@ -259,7 +263,7 @@ impl ExtBuilder {
         self
         self
     }
     }
     pub fn build(self) -> sp_io::TestExternalities {
     pub fn build(self) -> sp_io::TestExternalities {
-        let mut t = system::GenesisConfig::default()
+        let mut t = frame_system::GenesisConfig::default()
             .build_storage::<Test>()
             .build_storage::<Test>()
             .unwrap();
             .unwrap();
 
 
@@ -297,7 +301,7 @@ impl ExtBuilder {
 pub type TestDataObjectType = data_object_type_registry::DataObjectType;
 pub type TestDataObjectType = data_object_type_registry::DataObjectType;
 
 
 pub type Balances = balances::Module<Test>;
 pub type Balances = balances::Module<Test>;
-pub type System = system::Module<Test>;
+pub type System = frame_system::Module<Test>;
 pub type TestDataObjectTypeRegistry = data_object_type_registry::Module<Test>;
 pub type TestDataObjectTypeRegistry = data_object_type_registry::Module<Test>;
 pub type TestDataDirectory = data_directory::Module<Test>;
 pub type TestDataDirectory = data_directory::Module<Test>;
 pub type TestDataObjectStorageRegistry = data_object_storage_registry::Module<Test>;
 pub type TestDataObjectStorageRegistry = data_object_storage_registry::Module<Test>;

+ 10 - 10
runtime-modules/token-minting/Cargo.toml

@@ -1,20 +1,20 @@
 [package]
 [package]
 name = 'pallet-token-mint'
 name = 'pallet-token-mint'
-version = '3.0.0'
+version = '3.1.0'
 authors = ['Joystream contributors']
 authors = ['Joystream contributors']
 edition = '2018'
 edition = '2018'
 
 
 [dependencies]
 [dependencies]
-codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
-sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+codec = { package = 'parity-scale-codec', version = '1.3.4', default-features = false, features = ['derive'] }
+sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 
 
 [dev-dependencies]
 [dev-dependencies]
-sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 
 
 [features]
 [features]
 default = ['std']
 default = ['std']
@@ -23,5 +23,5 @@ std = [
 	'sp-arithmetic/std',
 	'sp-arithmetic/std',
 	'sp-runtime/std',
 	'sp-runtime/std',
 	'frame-support/std',
 	'frame-support/std',
-	'system/std',
+	'frame-system/std',
 ]
 ]

+ 3 - 3
runtime-modules/token-minting/src/lib.rs

@@ -19,7 +19,7 @@ mod tests;
 
 
 pub use mint::*;
 pub use mint::*;
 
 
-pub trait Trait: system::Trait {
+pub trait Trait: frame_system::Trait {
     /// The currency to mint.
     /// The currency to mint.
     type Currency: Currency<Self::AccountId>;
     type Currency: Currency<Self::AccountId>;
 
 
@@ -35,7 +35,7 @@ pub trait Trait: system::Trait {
 }
 }
 
 
 pub type BalanceOf<T> =
 pub type BalanceOf<T> =
-    <<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
+    <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
 
 
 #[derive(PartialEq, Eq, Debug)]
 #[derive(PartialEq, Eq, Debug)]
 pub enum GeneralError {
 pub enum GeneralError {
@@ -136,7 +136,7 @@ impl<T: Trait> Module<T> {
         initial_capacity: BalanceOf<T>,
         initial_capacity: BalanceOf<T>,
         adjustment: Option<Adjustment<BalanceOf<T>, T::BlockNumber>>,
         adjustment: Option<Adjustment<BalanceOf<T>, T::BlockNumber>>,
     ) -> Result<T::MintId, GeneralError> {
     ) -> Result<T::MintId, GeneralError> {
-        let now = <system::Module<T>>::block_number();
+        let now = <frame_system::Module<T>>::block_number();
 
 
         // Ensure the next adjustment if set, is in the future
         // Ensure the next adjustment if set, is in the future
         if let Some(adjustment) = adjustment {
         if let Some(adjustment) = adjustment {

+ 8 - 4
runtime-modules/token-minting/src/mock.rs

@@ -24,7 +24,7 @@ parameter_types! {
     pub const AvailableBlockRatio: Perbill = Perbill::one();
     pub const AvailableBlockRatio: Perbill = Perbill::one();
 }
 }
 
 
-impl system::Trait for Test {
+impl frame_system::Trait for Test {
     type BaseCallFilter = ();
     type BaseCallFilter = ();
     type Origin = Origin;
     type Origin = Origin;
     type Call = ();
     type Call = ();
@@ -45,10 +45,11 @@ impl system::Trait for Test {
     type MaximumBlockLength = MaximumBlockLength;
     type MaximumBlockLength = MaximumBlockLength;
     type AvailableBlockRatio = AvailableBlockRatio;
     type AvailableBlockRatio = AvailableBlockRatio;
     type Version = ();
     type Version = ();
-    type ModuleToIndex = ();
+    type PalletInfo = ();
     type AccountData = balances::AccountData<u64>;
     type AccountData = balances::AccountData<u64>;
     type OnNewAccount = ();
     type OnNewAccount = ();
     type OnKilledAccount = ();
     type OnKilledAccount = ();
+    type SystemWeightInfo = ();
 }
 }
 
 
 parameter_types! {
 parameter_types! {
@@ -57,6 +58,7 @@ parameter_types! {
     pub const CreationFee: u32 = 0;
     pub const CreationFee: u32 = 0;
     pub const TransactionBaseFee: u32 = 1;
     pub const TransactionBaseFee: u32 = 1;
     pub const TransactionByteFee: u32 = 0;
     pub const TransactionByteFee: u32 = 0;
+    pub const MaxLocks: u32 = 50;
 }
 }
 
 
 impl balances::Trait for Test {
 impl balances::Trait for Test {
@@ -65,6 +67,8 @@ impl balances::Trait for Test {
     type Event = ();
     type Event = ();
     type ExistentialDeposit = ExistentialDeposit;
     type ExistentialDeposit = ExistentialDeposit;
     type AccountStore = System;
     type AccountStore = System;
+    type WeightInfo = ();
+    type MaxLocks = MaxLocks;
 }
 }
 
 
 impl Trait for Test {
 impl Trait for Test {
@@ -73,13 +77,13 @@ impl Trait for Test {
 }
 }
 
 
 pub fn build_test_externalities() -> sp_io::TestExternalities {
 pub fn build_test_externalities() -> sp_io::TestExternalities {
-    let t = system::GenesisConfig::default()
+    let t = frame_system::GenesisConfig::default()
         .build_storage::<Test>()
         .build_storage::<Test>()
         .unwrap();
         .unwrap();
 
 
     t.into()
     t.into()
 }
 }
 
 
-pub type System = system::Module<Test>;
+pub type System = frame_system::Module<Test>;
 pub type Balances = balances::Module<Test>;
 pub type Balances = balances::Module<Test>;
 pub type Minting = Module<Test>;
 pub type Minting = Module<Test>;

+ 11 - 11
runtime-modules/versioned-store-permissions/Cargo.toml

@@ -1,23 +1,23 @@
 [package]
 [package]
 name = 'pallet-versioned-store-permissions'
 name = 'pallet-versioned-store-permissions'
-version = '3.0.0'
+version = '3.1.0'
 authors = ['Joystream contributors']
 authors = ['Joystream contributors']
 edition = '2018'
 edition = '2018'
 
 
 [dependencies]
 [dependencies]
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
 serde = { version = "1.0.101", optional = true, features = ["derive"] }
-codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
-sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+codec = { package = 'parity-scale-codec', version = '1.3.4', default-features = false, features = ['derive'] }
+sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 versioned-store = { package = 'pallet-versioned-store', default-features = false, path = '../versioned-store'}
 versioned-store = { package = 'pallet-versioned-store', default-features = false, path = '../versioned-store'}
 
 
 [dev-dependencies]
 [dev-dependencies]
-sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 common = { package = 'pallet-common', default-features = false, path = '../common'}
 common = { package = 'pallet-common', default-features = false, path = '../common'}
 
 
 [features]
 [features]
@@ -27,7 +27,7 @@ std = [
 	'codec/std',
 	'codec/std',
 	'sp-std/std',
 	'sp-std/std',
 	'frame-support/std',
 	'frame-support/std',
-	'system/std',
+	'frame-system/std',
 	'sp-arithmetic/std',
 	'sp-arithmetic/std',
 	'sp-runtime/std',
 	'sp-runtime/std',
     'versioned-store/std',
     'versioned-store/std',

+ 24 - 18
runtime-modules/versioned-store-permissions/src/lib.rs

@@ -61,10 +61,14 @@ impl<T: Trait> CreateClassPermissionsChecker<T> for () {
     }
     }
 }
 }
 
 
-pub type ClassPermissionsType<T> =
-    ClassPermissions<ClassId, <T as Trait>::Credential, u16, <T as system::Trait>::BlockNumber>;
-
-pub trait Trait: system::Trait + versioned_store::Trait {
+pub type ClassPermissionsType<T> = ClassPermissions<
+    ClassId,
+    <T as Trait>::Credential,
+    u16,
+    <T as frame_system::Trait>::BlockNumber,
+>;
+
+pub trait Trait: frame_system::Trait + versioned_store::Trait {
     /// Type that represents an actor or group of actors in the system.
     /// Type that represents an actor or group of actors in the system.
     type Credential: Parameter
     type Credential: Parameter
         + Member
         + Member
@@ -257,8 +261,8 @@ decl_module! {
             let raw_origin = Self::ensure_root_or_signed(origin)?;
             let raw_origin = Self::ensure_root_or_signed(origin)?;
 
 
             let can_create_class = match raw_origin {
             let can_create_class = match raw_origin {
-                system::RawOrigin::Root => true,
-                system::RawOrigin::Signed(sender) => {
+                frame_system::RawOrigin::Root => true,
+                frame_system::RawOrigin::Signed(sender) => {
                     T::CreateClassPermissionsChecker::account_can_create_class_permissions(&sender)
                     T::CreateClassPermissionsChecker::account_can_create_class_permissions(&sender)
                 },
                 },
                 _ => false
                 _ => false
@@ -387,16 +391,18 @@ decl_module! {
 impl<T: Trait> Module<T> {
 impl<T: Trait> Module<T> {
     fn ensure_root_or_signed(
     fn ensure_root_or_signed(
         origin: T::Origin,
         origin: T::Origin,
-    ) -> Result<system::RawOrigin<T::AccountId>, &'static str> {
+    ) -> Result<frame_system::RawOrigin<T::AccountId>, &'static str> {
         match origin.into() {
         match origin.into() {
-            Ok(system::RawOrigin::Root) => Ok(system::RawOrigin::Root),
-            Ok(system::RawOrigin::Signed(account_id)) => Ok(system::RawOrigin::Signed(account_id)),
+            Ok(frame_system::RawOrigin::Root) => Ok(frame_system::RawOrigin::Root),
+            Ok(frame_system::RawOrigin::Signed(account_id)) => {
+                Ok(frame_system::RawOrigin::Signed(account_id))
+            }
             _ => Err("BadOrigin:ExpectedRootOrSigned"),
             _ => Err("BadOrigin:ExpectedRootOrSigned"),
         }
         }
     }
     }
 
 
     fn do_create_entity(
     fn do_create_entity(
-        raw_origin: &system::RawOrigin<T::AccountId>,
+        raw_origin: &frame_system::RawOrigin<T::AccountId>,
         with_credential: Option<T::Credential>,
         with_credential: Option<T::Credential>,
         class_id: ClassId,
         class_id: ClassId,
     ) -> Result<EntityId, &'static str> {
     ) -> Result<EntityId, &'static str> {
@@ -425,7 +431,7 @@ impl<T: Trait> Module<T> {
     }
     }
 
 
     fn do_update_entity_property_values(
     fn do_update_entity_property_values(
-        raw_origin: &system::RawOrigin<T::AccountId>,
+        raw_origin: &frame_system::RawOrigin<T::AccountId>,
         with_credential: Option<T::Credential>,
         with_credential: Option<T::Credential>,
         as_entity_maintainer: bool,
         as_entity_maintainer: bool,
         entity_id: EntityId,
         entity_id: EntityId,
@@ -457,7 +463,7 @@ impl<T: Trait> Module<T> {
     }
     }
 
 
     fn do_add_schema_support_to_entity(
     fn do_add_schema_support_to_entity(
-        raw_origin: &system::RawOrigin<T::AccountId>,
+        raw_origin: &frame_system::RawOrigin<T::AccountId>,
         with_credential: Option<T::Credential>,
         with_credential: Option<T::Credential>,
         as_entity_maintainer: bool,
         as_entity_maintainer: bool,
         entity_id: EntityId,
         entity_id: EntityId,
@@ -494,13 +500,13 @@ impl<T: Trait> Module<T> {
     /// Derives the AccessLevel the caller is attempting to act with.
     /// Derives the AccessLevel the caller is attempting to act with.
     /// It expects only signed or root origin.
     /// It expects only signed or root origin.
     fn derive_access_level(
     fn derive_access_level(
-        raw_origin: &system::RawOrigin<T::AccountId>,
+        raw_origin: &frame_system::RawOrigin<T::AccountId>,
         with_credential: Option<T::Credential>,
         with_credential: Option<T::Credential>,
         as_entity_maintainer: Option<EntityId>,
         as_entity_maintainer: Option<EntityId>,
     ) -> Result<AccessLevel<T::Credential>, &'static str> {
     ) -> Result<AccessLevel<T::Credential>, &'static str> {
         match raw_origin {
         match raw_origin {
-            system::RawOrigin::Root => Ok(AccessLevel::System),
-            system::RawOrigin::Signed(account_id) => {
+            frame_system::RawOrigin::Root => Ok(AccessLevel::System),
+            frame_system::RawOrigin::Signed(account_id) => {
                 if let Some(credential) = with_credential {
                 if let Some(credential) = with_credential {
                     if T::CredentialChecker::account_has_credential(&account_id, credential) {
                     if T::CredentialChecker::account_has_credential(&account_id, credential) {
                         if let Some(entity_id) = as_entity_maintainer {
                         if let Some(entity_id) = as_entity_maintainer {
@@ -546,7 +552,7 @@ impl<T: Trait> Module<T> {
     /// Derives the access level of the caller.
     /// Derives the access level of the caller.
     /// If the predicate passes, the mutate method is invoked.
     /// If the predicate passes, the mutate method is invoked.
     fn mutate_class_permissions<Predicate, Mutate>(
     fn mutate_class_permissions<Predicate, Mutate>(
-        raw_origin: &system::RawOrigin<T::AccountId>,
+        raw_origin: &frame_system::RawOrigin<T::AccountId>,
         with_credential: Option<T::Credential>,
         with_credential: Option<T::Credential>,
         // predicate to test
         // predicate to test
         predicate: Predicate,
         predicate: Predicate,
@@ -564,7 +570,7 @@ impl<T: Trait> Module<T> {
 
 
         predicate(&class_permissions, &access_level)?;
         predicate(&class_permissions, &access_level)?;
         mutate(&mut class_permissions)?;
         mutate(&mut class_permissions)?;
-        class_permissions.last_permissions_update = <system::Module<T>>::block_number();
+        class_permissions.last_permissions_update = <frame_system::Module<T>>::block_number();
         <ClassPermissionsByClassId<T>>::insert(class_id, class_permissions);
         <ClassPermissionsByClassId<T>>::insert(class_id, class_permissions);
         Ok(())
         Ok(())
     }
     }
@@ -584,7 +590,7 @@ impl<T: Trait> Module<T> {
     /// If the peridcate passes the callback is invoked. Returns result of the callback
     /// If the peridcate passes the callback is invoked. Returns result of the callback
     /// or error from failed predicate.
     /// or error from failed predicate.
     fn if_class_permissions_satisfied<Predicate, Callback, R>(
     fn if_class_permissions_satisfied<Predicate, Callback, R>(
-        raw_origin: &system::RawOrigin<T::AccountId>,
+        raw_origin: &frame_system::RawOrigin<T::AccountId>,
         with_credential: Option<T::Credential>,
         with_credential: Option<T::Credential>,
         as_entity_maintainer: Option<EntityId>,
         as_entity_maintainer: Option<EntityId>,
         // predicate to test
         // predicate to test

+ 8 - 6
runtime-modules/versioned-store-permissions/src/mock.rs

@@ -27,7 +27,7 @@ parameter_types! {
     pub const MinimumPeriod: u64 = 5;
     pub const MinimumPeriod: u64 = 5;
 }
 }
 
 
-impl system::Trait for Runtime {
+impl frame_system::Trait for Runtime {
     type BaseCallFilter = ();
     type BaseCallFilter = ();
     type Origin = Origin;
     type Origin = Origin;
     type Call = ();
     type Call = ();
@@ -48,16 +48,18 @@ impl system::Trait for Runtime {
     type MaximumBlockLength = MaximumBlockLength;
     type MaximumBlockLength = MaximumBlockLength;
     type AvailableBlockRatio = AvailableBlockRatio;
     type AvailableBlockRatio = AvailableBlockRatio;
     type Version = ();
     type Version = ();
-    type ModuleToIndex = ();
+    type PalletInfo = ();
     type AccountData = ();
     type AccountData = ();
     type OnNewAccount = ();
     type OnNewAccount = ();
     type OnKilledAccount = ();
     type OnKilledAccount = ();
+    type SystemWeightInfo = ();
 }
 }
 
 
 impl pallet_timestamp::Trait for Runtime {
 impl pallet_timestamp::Trait for Runtime {
     type Moment = u64;
     type Moment = u64;
     type OnTimestampSet = ();
     type OnTimestampSet = ();
     type MinimumPeriod = MinimumPeriod;
     type MinimumPeriod = MinimumPeriod;
+    type WeightInfo = ();
 }
 }
 
 
 impl versioned_store::Trait for Runtime {
 impl versioned_store::Trait for Runtime {
@@ -90,7 +92,7 @@ pub struct MockCredentialChecker {}
 
 
 impl CredentialChecker<Runtime> for MockCredentialChecker {
 impl CredentialChecker<Runtime> for MockCredentialChecker {
     fn account_has_credential(
     fn account_has_credential(
-        account_id: &<Runtime as system::Trait>::AccountId,
+        account_id: &<Runtime as frame_system::Trait>::AccountId,
         credential_id: <Runtime as Trait>::Credential,
         credential_id: <Runtime as Trait>::Credential,
     ) -> bool {
     ) -> bool {
         if (credential_id as usize) < PRINCIPAL_GROUP_MEMBERS.len() {
         if (credential_id as usize) < PRINCIPAL_GROUP_MEMBERS.len() {
@@ -114,7 +116,7 @@ pub struct MockCreateClassPermissionsChecker {}
 
 
 impl CreateClassPermissionsChecker<Runtime> for MockCreateClassPermissionsChecker {
 impl CreateClassPermissionsChecker<Runtime> for MockCreateClassPermissionsChecker {
     fn account_can_create_class_permissions(
     fn account_can_create_class_permissions(
-        account_id: &<Runtime as system::Trait>::AccountId,
+        account_id: &<Runtime as frame_system::Trait>::AccountId,
     ) -> bool {
     ) -> bool {
         CLASS_PERMISSIONS_CREATORS
         CLASS_PERMISSIONS_CREATORS
             .iter()
             .iter()
@@ -151,7 +153,7 @@ fn default_versioned_store_genesis_config() -> versioned_store::GenesisConfig {
 }
 }
 
 
 fn build_test_externalities(config: versioned_store::GenesisConfig) -> sp_io::TestExternalities {
 fn build_test_externalities(config: versioned_store::GenesisConfig) -> sp_io::TestExternalities {
-    let mut t = system::GenesisConfig::default()
+    let mut t = frame_system::GenesisConfig::default()
         .build_storage::<Runtime>()
         .build_storage::<Runtime>()
         .unwrap();
         .unwrap();
 
 
@@ -165,7 +167,7 @@ pub fn with_test_externalities<R, F: FnOnce() -> R>(f: F) -> R {
     build_test_externalities(versioned_store_config).execute_with(f)
     build_test_externalities(versioned_store_config).execute_with(f)
 }
 }
 
 
-// pub type System = system::Module;
+// pub type System = frame_system::Module;
 
 
 /// Export module on a test runtime
 /// Export module on a test runtime
 pub type Permissions = Module<Runtime>;
 pub type Permissions = Module<Runtime>;

+ 13 - 13
runtime-modules/versioned-store-permissions/src/tests.rs

@@ -94,7 +94,7 @@ fn create_class_then_entity_with_default_class_permissions() {
         // give members of GROUP_ZERO permission to add schemas
         // give members of GROUP_ZERO permission to add schemas
         let add_schema_set = CredentialSet::from(vec![0]);
         let add_schema_set = CredentialSet::from(vec![0]);
         assert_ok!(Permissions::set_class_add_schemas_set(
         assert_ok!(Permissions::set_class_add_schemas_set(
-            system::RawOrigin::Root.into(),
+            frame_system::RawOrigin::Root.into(),
             None,
             None,
             class_id,
             class_id,
             add_schema_set
             add_schema_set
@@ -112,7 +112,7 @@ fn create_class_then_entity_with_default_class_permissions() {
         // System can always create entities (provided class exists) bypassing any permissions
         // System can always create entities (provided class exists) bypassing any permissions
         let entity_id_1 = next_entity_id();
         let entity_id_1 = next_entity_id();
         assert_ok!(Permissions::create_entity(
         assert_ok!(Permissions::create_entity(
-            system::RawOrigin::Root.into(),
+            frame_system::RawOrigin::Root.into(),
             None,
             None,
             class_id,
             class_id,
         ));
         ));
@@ -136,7 +136,7 @@ fn create_class_then_entity_with_default_class_permissions() {
         );
         );
 
 
         assert_ok!(Permissions::set_class_entities_can_be_created(
         assert_ok!(Permissions::set_class_entities_can_be_created(
-            system::RawOrigin::Root.into(),
+            frame_system::RawOrigin::Root.into(),
             None,
             None,
             class_id,
             class_id,
             true
             true
@@ -154,7 +154,7 @@ fn create_class_then_entity_with_default_class_permissions() {
         // give members of GROUP_ONE permission to create entities
         // give members of GROUP_ONE permission to create entities
         let create_entities_set = CredentialSet::from(vec![1]);
         let create_entities_set = CredentialSet::from(vec![1]);
         assert_ok!(Permissions::set_class_create_entities_set(
         assert_ok!(Permissions::set_class_create_entities_set(
-            system::RawOrigin::Root.into(),
+            frame_system::RawOrigin::Root.into(),
             None,
             None,
             class_id,
             class_id,
             create_entities_set
             create_entities_set
@@ -224,7 +224,7 @@ fn class_permissions_set_admins() {
         );
         );
         assert_err!(
         assert_err!(
             Permissions::set_class_admins(
             Permissions::set_class_admins(
-                system::RawOrigin::None.into(), //unsigned inherent?
+                frame_system::RawOrigin::None.into(), //unsigned inherent?
                 class_id,
                 class_id,
                 credential_set.clone()
                 credential_set.clone()
             ),
             ),
@@ -233,7 +233,7 @@ fn class_permissions_set_admins() {
 
 
         // root origin can set admins
         // root origin can set admins
         assert_ok!(Permissions::set_class_admins(
         assert_ok!(Permissions::set_class_admins(
-            system::RawOrigin::Root.into(),
+            frame_system::RawOrigin::Root.into(),
             class_id,
             class_id,
             credential_set.clone()
             credential_set.clone()
         ));
         ));
@@ -258,7 +258,7 @@ fn class_permissions_set_add_schemas_set() {
 
 
         // root
         // root
         assert_ok!(Permissions::set_class_add_schemas_set(
         assert_ok!(Permissions::set_class_add_schemas_set(
-            system::RawOrigin::Root.into(),
+            frame_system::RawOrigin::Root.into(),
             None,
             None,
             class_id,
             class_id,
             credential_set1.clone()
             credential_set1.clone()
@@ -304,7 +304,7 @@ fn class_permissions_set_class_create_entities_set() {
 
 
         // root
         // root
         assert_ok!(Permissions::set_class_create_entities_set(
         assert_ok!(Permissions::set_class_create_entities_set(
-            system::RawOrigin::Root.into(),
+            frame_system::RawOrigin::Root.into(),
             None,
             None,
             class_id,
             class_id,
             credential_set1.clone()
             credential_set1.clone()
@@ -347,7 +347,7 @@ fn class_permissions_set_class_entities_can_be_created() {
 
 
         // root
         // root
         assert_ok!(Permissions::set_class_entities_can_be_created(
         assert_ok!(Permissions::set_class_entities_can_be_created(
-            system::RawOrigin::Root.into(),
+            frame_system::RawOrigin::Root.into(),
             None,
             None,
             class_id,
             class_id,
             true
             true
@@ -395,7 +395,7 @@ fn class_permissions_set_class_entity_permissions() {
 
 
         //root
         //root
         assert_ok!(Permissions::set_class_entity_permissions(
         assert_ok!(Permissions::set_class_entity_permissions(
-            system::RawOrigin::Root.into(),
+            frame_system::RawOrigin::Root.into(),
             None,
             None,
             class_id,
             class_id,
             entity_permissions1.clone()
             entity_permissions1.clone()
@@ -449,7 +449,7 @@ fn class_permissions_set_class_reference_constraint() {
 
 
         //root
         //root
         assert_ok!(Permissions::set_class_reference_constraint(
         assert_ok!(Permissions::set_class_reference_constraint(
-            system::RawOrigin::Root.into(),
+            frame_system::RawOrigin::Root.into(),
             None,
             None,
             class_id,
             class_id,
             reference_constraint1.clone()
             reference_constraint1.clone()
@@ -513,7 +513,7 @@ fn batch_transaction_simple() {
         }];
         }];
 
 
         assert_ok!(Permissions::add_class_schema(
         assert_ok!(Permissions::add_class_schema(
-            system::RawOrigin::Root.into(),
+            frame_system::RawOrigin::Root.into(),
             None,
             None,
             new_class_id,
             new_class_id,
             vec![],
             vec![],
@@ -597,7 +597,7 @@ fn batch_transaction_vector_of_entities() {
         }];
         }];
 
 
         assert_ok!(Permissions::add_class_schema(
         assert_ok!(Permissions::add_class_schema(
-            system::RawOrigin::Root.into(),
+            frame_system::RawOrigin::Root.into(),
             None,
             None,
             new_class_id,
             new_class_id,
             vec![],
             vec![],

Some files were not shown because too many files changed in this diff