mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 22:21:02 +00:00
Compact format for block number, nonce, balance (#910)
* Try to make everything compact * Make `Clone` work * Fix * Move contracts and balances over to compact encoding * Session and timestamp are compact * Sataking uses compact numbers * Treasury now compact * Compact Democracy * Council is compact * Fix
This commit is contained in:
Generated
+52
-51
@@ -585,7 +585,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
@@ -721,12 +721,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hash-db"
|
||||
version = "0.9.0"
|
||||
source = "git+https://github.com/paritytech/trie#e61df32342920f602a9d8d71caa5117c779d3ff1"
|
||||
source = "git+https://github.com/paritytech/trie#2616db2a2529098949e5d39aa06dd4e502a9e5f7"
|
||||
|
||||
[[package]]
|
||||
name = "hash256-std-hasher"
|
||||
version = "0.9.0"
|
||||
source = "git+https://github.com/paritytech/trie#e61df32342920f602a9d8d71caa5117c779d3ff1"
|
||||
source = "git+https://github.com/paritytech/trie#2616db2a2529098949e5d39aa06dd4e502a9e5f7"
|
||||
dependencies = [
|
||||
"crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
@@ -968,7 +968,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "keccak-hasher"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/paritytech/trie#e61df32342920f602a9d8d71caa5117c779d3ff1"
|
||||
source = "git+https://github.com/paritytech/trie#2616db2a2529098949e5d39aa06dd4e502a9e5f7"
|
||||
dependencies = [
|
||||
"hash-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"hash256-std-hasher 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
@@ -1436,7 +1436,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
[[package]]
|
||||
name = "memory-db"
|
||||
version = "0.9.0"
|
||||
source = "git+https://github.com/paritytech/trie#e61df32342920f602a9d8d71caa5117c779d3ff1"
|
||||
source = "git+https://github.com/paritytech/trie#2616db2a2529098949e5d39aa06dd4e502a9e5f7"
|
||||
dependencies = [
|
||||
"hash-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -1610,7 +1610,7 @@ dependencies = [
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"node-primitives 0.1.0",
|
||||
"node-runtime 0.1.0",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rhododendron 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 0.1.0",
|
||||
@@ -1629,7 +1629,7 @@ dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"node-primitives 0.1.0",
|
||||
"node-runtime 0.1.0",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 0.1.0",
|
||||
"sr-primitives 0.1.0",
|
||||
"srml-balances 0.1.0",
|
||||
@@ -1669,7 +1669,7 @@ dependencies = [
|
||||
name = "node-primitives"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pretty_assertions 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -1686,7 +1686,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"node-primitives 0.1.0",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -1726,7 +1726,7 @@ dependencies = [
|
||||
"node-network 0.1.0",
|
||||
"node-primitives 0.1.0",
|
||||
"node-runtime 0.1.0",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rhododendron 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -1864,10 +1864,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "parity-codec"
|
||||
version = "2.0.3"
|
||||
version = "2.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2238,7 +2239,7 @@ dependencies = [
|
||||
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@@ -2519,7 +2520,7 @@ dependencies = [
|
||||
name = "sr-api"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 0.1.0",
|
||||
"sr-std 0.1.0",
|
||||
@@ -2532,7 +2533,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"environmental 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hash-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-std 0.1.0",
|
||||
"substrate-primitives 0.1.0",
|
||||
@@ -2547,7 +2548,7 @@ dependencies = [
|
||||
"integer-sqrt 0.1.0 (git+https://github.com/paritytech/integer-sqrt-rs.git)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -2563,7 +2564,7 @@ name = "sr-sandbox"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-std 0.1.0",
|
||||
"substrate-primitives 0.1.0",
|
||||
@@ -2582,7 +2583,7 @@ dependencies = [
|
||||
name = "sr-version"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -2594,7 +2595,7 @@ name = "srml-balances"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -2613,7 +2614,7 @@ name = "srml-consensus"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -2630,7 +2631,7 @@ name = "srml-contract"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pwasm-utils 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -2652,7 +2653,7 @@ name = "srml-council"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -2672,7 +2673,7 @@ name = "srml-democracy"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -2691,7 +2692,7 @@ name = "srml-example"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -2709,7 +2710,7 @@ name = "srml-executive"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -2727,7 +2728,7 @@ name = "srml-session"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -2747,7 +2748,7 @@ name = "srml-staking"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -2771,7 +2772,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mashup 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -2787,7 +2788,7 @@ name = "srml-system"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -2804,7 +2805,7 @@ name = "srml-timestamp"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 0.1.0",
|
||||
@@ -2821,7 +2822,7 @@ name = "srml-treasury"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -2926,7 +2927,7 @@ dependencies = [
|
||||
"kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-api 0.1.0",
|
||||
@@ -2950,7 +2951,7 @@ dependencies = [
|
||||
"kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"kvdb-rocksdb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 0.1.0",
|
||||
@@ -3004,7 +3005,7 @@ dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -3025,7 +3026,7 @@ dependencies = [
|
||||
"finality-grandpa 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 0.1.0",
|
||||
"substrate-client 0.1.0",
|
||||
@@ -3064,7 +3065,7 @@ dependencies = [
|
||||
name = "substrate-metadata"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -3080,7 +3081,7 @@ dependencies = [
|
||||
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -3131,7 +3132,7 @@ dependencies = [
|
||||
"hash256-std-hasher 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pretty_assertions 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -3157,7 +3158,7 @@ dependencies = [
|
||||
"jsonrpc-macros 9.0.0 (git+https://github.com/paritytech/jsonrpc.git)",
|
||||
"jsonrpc-pubsub 9.0.0 (git+https://github.com/paritytech/jsonrpc.git)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 0.1.0",
|
||||
@@ -3200,7 +3201,7 @@ dependencies = [
|
||||
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -3245,7 +3246,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"substrate-primitives 0.1.0",
|
||||
@@ -3259,7 +3260,7 @@ dependencies = [
|
||||
"heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"substrate-primitives 0.1.0",
|
||||
"substrate-trie 0.4.0",
|
||||
@@ -3285,7 +3286,7 @@ dependencies = [
|
||||
name = "substrate-test-client"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 0.1.0",
|
||||
"substrate-client 0.1.0",
|
||||
"substrate-executor 0.1.0",
|
||||
@@ -3300,7 +3301,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -3334,7 +3335,7 @@ dependencies = [
|
||||
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 0.1.0",
|
||||
"substrate-client 0.1.0",
|
||||
@@ -3353,7 +3354,7 @@ dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"keccak-hasher 0.1.0 (git+https://github.com/paritytech/trie)",
|
||||
"memory-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"substrate-primitives 0.1.0",
|
||||
"trie-bench 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"trie-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
@@ -3728,13 +3729,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
[[package]]
|
||||
name = "trie-bench"
|
||||
version = "0.9.0"
|
||||
source = "git+https://github.com/paritytech/trie#e61df32342920f602a9d8d71caa5117c779d3ff1"
|
||||
source = "git+https://github.com/paritytech/trie#2616db2a2529098949e5d39aa06dd4e502a9e5f7"
|
||||
dependencies = [
|
||||
"criterion 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hash-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"keccak-hasher 0.1.0 (git+https://github.com/paritytech/trie)",
|
||||
"memory-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"trie-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"trie-root 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"trie-standardmap 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
@@ -3743,7 +3744,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "trie-db"
|
||||
version = "0.9.0"
|
||||
source = "git+https://github.com/paritytech/trie#e61df32342920f602a9d8d71caa5117c779d3ff1"
|
||||
source = "git+https://github.com/paritytech/trie#2616db2a2529098949e5d39aa06dd4e502a9e5f7"
|
||||
dependencies = [
|
||||
"elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hash-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
@@ -3754,7 +3755,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "trie-root"
|
||||
version = "0.9.0"
|
||||
source = "git+https://github.com/paritytech/trie#e61df32342920f602a9d8d71caa5117c779d3ff1"
|
||||
source = "git+https://github.com/paritytech/trie#2616db2a2529098949e5d39aa06dd4e502a9e5f7"
|
||||
dependencies = [
|
||||
"hash-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
]
|
||||
@@ -3762,7 +3763,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "trie-standardmap"
|
||||
version = "0.9.0"
|
||||
source = "git+https://github.com/paritytech/trie#e61df32342920f602a9d8d71caa5117c779d3ff1"
|
||||
source = "git+https://github.com/paritytech/trie#2616db2a2529098949e5d39aa06dd4e502a9e5f7"
|
||||
dependencies = [
|
||||
"criterion 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hash-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
@@ -4289,7 +4290,7 @@ dependencies = [
|
||||
"checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37"
|
||||
"checksum parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa5168b4cf41f3835e4bc6ffb32f51bc9365dc50cb351904595b3931d917fd0c"
|
||||
"checksum parity-codec 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bee4edfcfa19892f7178cb299a659866015dc131459865a1d808269cf7e7eb9e"
|
||||
"checksum parity-codec 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "63c4b16ee2b7d6aace13b09bb0d16ade6b90ef19b7ca1c6cec9b8d08b9f59ecb"
|
||||
"checksum parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "dca389ea5e1632c89b2ce54f7e2b4a8a8c9d278042222a91e0bf95451218cb4c"
|
||||
"checksum parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ffa42c2cb493b60b12c75b26e8c94cb734af4df4d7f2cc229dc04c1953dac189"
|
||||
"checksum parity-crypto 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c1117f6574377d21309bfa1f7d69ff734120685d92b02c3f362b122585758840"
|
||||
"checksum parity-rocksdb 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cd55d2d6d6000ec99f021cf52c9acc7d2a402e14f95ced4c5de230696fabe00b"
|
||||
|
||||
@@ -13,7 +13,7 @@ futures = "0.1.17"
|
||||
slog = "^2"
|
||||
heapsize = "0.4"
|
||||
substrate-consensus-rhd = { path = "../consensus/rhd" }
|
||||
parity-codec = "2.0"
|
||||
parity-codec = "2.1"
|
||||
substrate-executor = { path = "../executor" }
|
||||
substrate-primitives = { path = "../primitives" }
|
||||
sr-primitives = { path = "../sr-primitives" }
|
||||
|
||||
@@ -13,8 +13,8 @@ substrate-primitives = { path = "../../primitives" }
|
||||
sr-primitives = { path = "../../sr-primitives" }
|
||||
substrate-client = { path = "../../client" }
|
||||
substrate-state-machine = { path = "../../state-machine" }
|
||||
parity-codec = "2.0"
|
||||
parity-codec-derive = "2.0"
|
||||
parity-codec = "2.1"
|
||||
parity-codec-derive = "2.1"
|
||||
substrate-executor = { path = "../../executor" }
|
||||
substrate-state-db = { path = "../../state-db" }
|
||||
substrate-trie = { path = "../../trie" }
|
||||
|
||||
@@ -216,8 +216,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn is_build_required_works() {
|
||||
assert_eq!(is_build_required(SIZE, 0), None);
|
||||
assert_eq!(is_build_required(SIZE, 1), None);
|
||||
assert_eq!(is_build_required(SIZE, 0u64), None);
|
||||
assert_eq!(is_build_required(SIZE, 1u64), None);
|
||||
assert_eq!(is_build_required(SIZE, SIZE), None);
|
||||
assert_eq!(is_build_required(SIZE, SIZE + 1), None);
|
||||
assert_eq!(is_build_required(SIZE, 2 * SIZE), None);
|
||||
@@ -228,16 +228,16 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn start_number_works() {
|
||||
assert_eq!(start_number(SIZE, 0), 1);
|
||||
assert_eq!(start_number(SIZE, 1), SIZE + 1);
|
||||
assert_eq!(start_number(SIZE, 2), SIZE + SIZE + 1);
|
||||
assert_eq!(start_number(SIZE, 0u64), 1u64);
|
||||
assert_eq!(start_number(SIZE, 1u64), SIZE + 1);
|
||||
assert_eq!(start_number(SIZE, 2u64), SIZE + SIZE + 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn end_number_works() {
|
||||
assert_eq!(end_number(SIZE, 0), SIZE);
|
||||
assert_eq!(end_number(SIZE, 1), SIZE + SIZE);
|
||||
assert_eq!(end_number(SIZE, 2), SIZE + SIZE + SIZE);
|
||||
assert_eq!(end_number(SIZE, 0u64), SIZE);
|
||||
assert_eq!(end_number(SIZE, 1u64), SIZE + SIZE);
|
||||
assert_eq!(end_number(SIZE, 2u64), SIZE + SIZE + SIZE);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
|
||||
[dependencies]
|
||||
error-chain = "0.12"
|
||||
parity-codec = "2.0"
|
||||
parity-codec = "2.1"
|
||||
sr-io = { path = "../sr-io" }
|
||||
substrate-primitives = { path = "../primitives" }
|
||||
substrate-trie = { path = "../trie" }
|
||||
|
||||
Generated
+8
-8
@@ -41,7 +41,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "parity-codec"
|
||||
version = "2.0.2"
|
||||
version = "2.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -49,7 +49,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "parity-codec-derive"
|
||||
version = "2.0.3"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -118,7 +118,7 @@ name = "sr-io"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hash-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-std 0.1.0",
|
||||
"substrate-primitives 0.1.0",
|
||||
@@ -128,7 +128,7 @@ dependencies = [
|
||||
name = "sr-sandbox"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-std 0.1.0",
|
||||
"substrate-primitives 0.1.0",
|
||||
@@ -150,8 +150,8 @@ dependencies = [
|
||||
"fixed-hash 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hash-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"hash256-std-hasher 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-std 0.1.0",
|
||||
@@ -191,8 +191,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum hash-db 0.9.0 (git+https://github.com/paritytech/trie)" = "<none>"
|
||||
"checksum hash256-std-hasher 0.9.0 (git+https://github.com/paritytech/trie)" = "<none>"
|
||||
"checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2"
|
||||
"checksum parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "df92a55cfa11e8e964e9f0e74b257e21086098d6d3e3fbb2f8fcb17bcbb8e1a1"
|
||||
"checksum parity-codec-derive 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b250f2968bba91133dee9d23d2a8b7a62443cde68921f17b647fabbe3e09d67d"
|
||||
"checksum parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "dca389ea5e1632c89b2ce54f7e2b4a8a8c9d278042222a91e0bf95451218cb4c"
|
||||
"checksum parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ffa42c2cb493b60b12c75b26e8c94cb734af4df4d7f2cc229dc04c1953dac189"
|
||||
"checksum proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)" = "ffe022fb8c8bd254524b0b3305906c1921fa37a84a644e29079a9e62200c3901"
|
||||
"checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5"
|
||||
"checksum rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8"
|
||||
|
||||
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
|
||||
[dependencies]
|
||||
futures = "0.1.17"
|
||||
parity-codec = "2.0"
|
||||
parity-codec = "2.1"
|
||||
sr-primitives = { path = "../sr-primitives" }
|
||||
substrate-primitives = { path = "../primitives" }
|
||||
substrate-client = { path = "../client" }
|
||||
|
||||
@@ -19,8 +19,8 @@ rand = "0.5"
|
||||
substrate-primitives = { path = "../../core/primitives" }
|
||||
substrate-client = { path = "../../core/client" }
|
||||
sr-primitives = { path = "../../core/sr-primitives" }
|
||||
parity-codec = "2.0"
|
||||
parity-codec-derive = "2.0"
|
||||
parity-codec = "2.1"
|
||||
parity-codec-derive = "2.1"
|
||||
substrate-network-libp2p = { path = "../../core/network-libp2p" }
|
||||
tokio = "0.1.11"
|
||||
|
||||
|
||||
@@ -820,7 +820,7 @@ pub mod tests {
|
||||
});
|
||||
let thread = ::std::thread::spawn(move || {
|
||||
let result = response.wait().unwrap();
|
||||
assert_eq!(result.hash(), "0x950856031909d22d42b7e11a837051fbde05beaa3ffb793d6e8e373c646459b1".into());
|
||||
assert_eq!(result.hash(), "0x6443a0b46e0412e626363028115a9f2cf963eeed526b8b33e5316f08b50d0dc3".into());
|
||||
});
|
||||
|
||||
on_demand.on_remote_header_response(&mut network, 0, message::RemoteHeaderResponse {
|
||||
|
||||
@@ -416,6 +416,7 @@ impl<B: BlockT, S: Specialization<B>, H: ExHashT> Protocol<B, S, H> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn peer_info(&self, peer: NodeIndex) -> Option<PeerInfo<B>> {
|
||||
self.context_data.peers.read().get(&peer).map(|p| {
|
||||
PeerInfo {
|
||||
|
||||
@@ -6,8 +6,8 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
[dependencies]
|
||||
crunchy = "0.1"
|
||||
sr-std = { path = "../sr-std", default-features = false }
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec-derive = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
parity-codec-derive = { version = "2.1", default-features = false }
|
||||
fixed-hash = { version = "0.2.2", default-features = false }
|
||||
rustc-hex = { version = "2.0", default-features = false }
|
||||
serde = { version = "1.0", default-features = false }
|
||||
|
||||
@@ -10,7 +10,7 @@ jsonrpc-macros = { git="https://github.com/paritytech/jsonrpc.git" }
|
||||
jsonrpc-pubsub = { git="https://github.com/paritytech/jsonrpc.git" }
|
||||
log = "0.4"
|
||||
parking_lot = "0.4"
|
||||
parity-codec = "2.0"
|
||||
parity-codec = "2.1"
|
||||
substrate-client = { path = "../client" }
|
||||
substrate-executor = { path = "../executor" }
|
||||
substrate-transaction-pool = { path = "../transaction-pool" }
|
||||
|
||||
@@ -23,7 +23,7 @@ substrate-primitives = { path = "../../core/primitives" }
|
||||
substrate-network = { path = "../../core/network" }
|
||||
substrate-client = { path = "../../core/client" }
|
||||
substrate-client-db = { path = "../../core/client/db" }
|
||||
parity-codec = "2.0"
|
||||
parity-codec = "2.1"
|
||||
substrate-executor = { path = "../../core/executor" }
|
||||
substrate-transaction-pool = { path = "../../core/transaction-pool" }
|
||||
substrate-rpc = { path = "../../core/rpc" }
|
||||
|
||||
@@ -4,7 +4,7 @@ version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
|
||||
[dependencies]
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
parity-codec-derive = { version = "2.1", default-features = false }
|
||||
sr-std = { path = "../sr-std", default-features = false }
|
||||
sr-primitives = { path = "../sr-primitives", default-features = false }
|
||||
|
||||
@@ -10,7 +10,7 @@ rustc_version = "0.2"
|
||||
[dependencies]
|
||||
sr-std = { path = "../sr-std", default-features = false }
|
||||
substrate-primitives = { path = "../primitives", default-features = false }
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
hash-db = { git = "https://github.com/paritytech/trie", default-features = false }
|
||||
|
||||
environmental = { version = "~1.0", optional = true }
|
||||
|
||||
@@ -8,8 +8,8 @@ num-traits = { version = "0.2", default-features = false }
|
||||
integer-sqrt = { git = "https://github.com/paritytech/integer-sqrt-rs.git", branch = "master" }
|
||||
serde = { version = "1.0", optional = true }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec-derive = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
parity-codec-derive = { version = "2.1", default-features = false }
|
||||
substrate-primitives = { path = "../primitives", default-features = false }
|
||||
sr-std = { path = "../sr-std", default-features = false }
|
||||
sr-io = { path = "../sr-io", default-features = false }
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#[cfg(feature = "std")]
|
||||
use serde::{Deserialize, Deserializer};
|
||||
|
||||
use codec::{Decode, Encode, Codec, Input, Output};
|
||||
use codec::{Decode, Encode, Codec, Input, Output, HasCompact};
|
||||
use traits::{self, Member, SimpleArithmetic, SimpleBitOps, MaybeDisplay,
|
||||
Hash as HashT, DigestItem as DigestItemT};
|
||||
use generic::Digest;
|
||||
@@ -82,7 +82,7 @@ impl<'a, Number: 'a, Hash: 'a + HashT, DigestItem: 'a> Deserialize<'a> for Heade
|
||||
}
|
||||
|
||||
impl<Number, Hash, DigestItem> Decode for Header<Number, Hash, DigestItem> where
|
||||
Number: Decode,
|
||||
Number: HasCompact,
|
||||
Hash: HashT,
|
||||
Hash::Output: Decode,
|
||||
DigestItem: DigestItemT + Decode,
|
||||
@@ -90,7 +90,7 @@ impl<Number, Hash, DigestItem> Decode for Header<Number, Hash, DigestItem> where
|
||||
fn decode<I: Input>(input: &mut I) -> Option<Self> {
|
||||
Some(Header {
|
||||
parent_hash: Decode::decode(input)?,
|
||||
number: Decode::decode(input)?,
|
||||
number: <<Number as HasCompact>::Type>::decode(input)?.into(),
|
||||
state_root: Decode::decode(input)?,
|
||||
extrinsics_root: Decode::decode(input)?,
|
||||
digest: Decode::decode(input)?,
|
||||
@@ -99,14 +99,14 @@ impl<Number, Hash, DigestItem> Decode for Header<Number, Hash, DigestItem> where
|
||||
}
|
||||
|
||||
impl<Number, Hash, DigestItem> Encode for Header<Number, Hash, DigestItem> where
|
||||
Number: Encode,
|
||||
Number: HasCompact + Copy,
|
||||
Hash: HashT,
|
||||
Hash::Output: Encode,
|
||||
DigestItem: DigestItemT + Encode,
|
||||
{
|
||||
fn encode_to<T: Output>(&self, dest: &mut T) {
|
||||
dest.push(&self.parent_hash);
|
||||
dest.push(&self.number);
|
||||
dest.push(&<<Number as HasCompact>::Type>::from(self.number));
|
||||
dest.push(&self.state_root);
|
||||
dest.push(&self.extrinsics_root);
|
||||
dest.push(&self.digest);
|
||||
@@ -114,7 +114,7 @@ impl<Number, Hash, DigestItem> Encode for Header<Number, Hash, DigestItem> where
|
||||
}
|
||||
|
||||
impl<Number, Hash, DigestItem> traits::Header for Header<Number, Hash, DigestItem> where
|
||||
Number: Member + ::rstd::hash::Hash + Copy + Codec + MaybeDisplay + SimpleArithmetic + Codec,
|
||||
Number: Member + ::rstd::hash::Hash + Copy + MaybeDisplay + SimpleArithmetic + Codec,
|
||||
Hash: HashT,
|
||||
DigestItem: DigestItemT<Hash = Hash::Output> + Codec,
|
||||
Hash::Output: Default + ::rstd::hash::Hash + Copy + Member + MaybeDisplay + SimpleBitOps + Codec,
|
||||
@@ -157,7 +157,7 @@ impl<Number, Hash, DigestItem> traits::Header for Header<Number, Hash, DigestIte
|
||||
}
|
||||
|
||||
impl<Number, Hash, DigestItem> Header<Number, Hash, DigestItem> where
|
||||
Number: Member + ::rstd::hash::Hash + Copy + Codec + MaybeDisplay + SimpleArithmetic + Codec,
|
||||
Number: Member + ::rstd::hash::Hash + Copy + MaybeDisplay + SimpleArithmetic + Codec,
|
||||
Hash: HashT,
|
||||
DigestItem: DigestItemT + Codec,
|
||||
Hash::Output: Default + ::rstd::hash::Hash + Copy + Member + MaybeDisplay + SimpleBitOps + Codec,
|
||||
|
||||
@@ -20,27 +20,50 @@
|
||||
use std::fmt;
|
||||
|
||||
use rstd::prelude::*;
|
||||
use codec::{Decode, Encode, Input};
|
||||
use codec::{Decode, Encode, Codec, Input, HasCompact};
|
||||
use traits::{self, Member, SimpleArithmetic, MaybeDisplay, Lookup};
|
||||
use super::CheckedExtrinsic;
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||
pub struct SignatureContent<Address, Index, Signature>
|
||||
where
|
||||
Address: Codec,
|
||||
Index: HasCompact + Codec,
|
||||
Signature: Codec,
|
||||
{
|
||||
signed: Address,
|
||||
signature: Signature,
|
||||
index: Index,
|
||||
}
|
||||
|
||||
/// A extrinsic right from the external world. This is unchecked and so
|
||||
/// can contain a signature.
|
||||
#[derive(PartialEq, Eq, Clone)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||
pub struct UncheckedExtrinsic<Address, Index, Call, Signature> {
|
||||
pub struct UncheckedExtrinsic<Address, Index, Call, Signature>
|
||||
where
|
||||
Address: Codec,
|
||||
Index: HasCompact + Codec,
|
||||
Signature: Codec,
|
||||
{
|
||||
/// The signature, address and number of extrinsics have come before from
|
||||
/// the same signer, if this is a signed extrinsic.
|
||||
pub signature: Option<(Address, Signature, Index)>,
|
||||
pub signature: Option<SignatureContent<Address, Index, Signature>>,
|
||||
/// The function that should be called.
|
||||
pub function: Call,
|
||||
}
|
||||
|
||||
impl<Address, Index, Call, Signature> UncheckedExtrinsic<Address, Index, Call, Signature> {
|
||||
impl<Address, Index, Signature, Call> UncheckedExtrinsic<Address, Index, Call, Signature>
|
||||
where
|
||||
Address: Codec,
|
||||
Index: HasCompact + Codec,
|
||||
Signature: Codec,
|
||||
{
|
||||
/// New instance of a signed extrinsic aka "transaction".
|
||||
pub fn new_signed(index: Index, function: Call, signed: Address, signature: Signature) -> Self {
|
||||
UncheckedExtrinsic {
|
||||
signature: Some((signed, signature, index)),
|
||||
signature: Some(SignatureContent{signed, signature, index}),
|
||||
function,
|
||||
}
|
||||
}
|
||||
@@ -59,13 +82,13 @@ impl<Address, Index, Call, Signature> UncheckedExtrinsic<Address, Index, Call, S
|
||||
}
|
||||
}
|
||||
|
||||
impl<Address, AccountId, Index, Call, Signature, Context> traits::Checkable<Context>
|
||||
impl<Address, Index, Signature, Call, AccountId, Context> traits::Checkable<Context>
|
||||
for UncheckedExtrinsic<Address, Index, Call, Signature>
|
||||
where
|
||||
Address: Member + MaybeDisplay,
|
||||
Index: Encode + Member + MaybeDisplay + SimpleArithmetic,
|
||||
Address: Member + MaybeDisplay + Codec,
|
||||
Index: Member + MaybeDisplay + SimpleArithmetic + Codec,
|
||||
Call: Encode + Member,
|
||||
Signature: Member + traits::Verify<Signer=AccountId>,
|
||||
Signature: Member + traits::Verify<Signer=AccountId> + Codec,
|
||||
AccountId: Member + MaybeDisplay,
|
||||
Context: Lookup<Source=Address, Target=AccountId>,
|
||||
{
|
||||
@@ -73,7 +96,7 @@ where
|
||||
|
||||
fn check(self, context: &Context) -> Result<Self::Checked, &'static str> {
|
||||
Ok(match self.signature {
|
||||
Some((signed, signature, index)) => {
|
||||
Some(SignatureContent{signed, signature, index}) => {
|
||||
let payload = (index, self.function);
|
||||
let signed = context.lookup(signed)?;
|
||||
if !::verify_encoded_lazy(&signature, &payload, &signed) {
|
||||
@@ -92,13 +115,8 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<Address, Index, Call, Signature> Decode
|
||||
impl<Address: Codec, Index: HasCompact + Codec, Signature: Codec, Call: Decode> Decode
|
||||
for UncheckedExtrinsic<Address, Index, Call, Signature>
|
||||
where
|
||||
Address: Decode,
|
||||
Signature: Decode,
|
||||
Index: Decode,
|
||||
Call: Decode,
|
||||
{
|
||||
fn decode<I: Input>(input: &mut I) -> Option<Self> {
|
||||
// This is a little more complicated than usual since the binary format must be compatible
|
||||
@@ -114,13 +132,8 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<Address, Index, Call, Signature> Encode
|
||||
impl<Address: Codec, Index: HasCompact + Codec, Signature: Codec, Call: Encode> Encode
|
||||
for UncheckedExtrinsic<Address, Index, Call, Signature>
|
||||
where
|
||||
Address: Encode,
|
||||
Signature: Encode,
|
||||
Index: Encode,
|
||||
Call: Encode,
|
||||
{
|
||||
fn encode(&self) -> Vec<u8> {
|
||||
super::encode_with_vec_prefix::<Self, _>(|v| {
|
||||
@@ -132,13 +145,16 @@ where
|
||||
|
||||
/// TODO: use derive when possible.
|
||||
#[cfg(feature = "std")]
|
||||
impl<Address, Index, Call, Signature> fmt::Debug for UncheckedExtrinsic<Address, Index, Call, Signature> where
|
||||
Address: fmt::Debug,
|
||||
Index: fmt::Debug,
|
||||
impl<Address, Index, Signature, Call> fmt::Debug
|
||||
for UncheckedExtrinsic<Address, Index, Call, Signature>
|
||||
where
|
||||
Address: fmt::Debug + Codec,
|
||||
Index: fmt::Debug + HasCompact + Codec,
|
||||
Signature: Codec,
|
||||
Call: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "UncheckedExtrinsic({:?}, {:?})", self.signature.as_ref().map(|x| (&x.0, &x.2)), self.function)
|
||||
write!(f, "UncheckedExtrinsic({:?}, {:?})", self.signature.as_ref().map(|x| (&x.signed, &x.index)), self.function)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ use runtime_io;
|
||||
#[cfg(feature = "std")] use serde::{Serialize, de::DeserializeOwned};
|
||||
use substrate_primitives;
|
||||
use substrate_primitives::Blake2Hasher;
|
||||
use codec::{Codec, Encode};
|
||||
use codec::{Codec, Encode, HasCompact};
|
||||
pub use integer_sqrt::IntegerSquareRoot;
|
||||
pub use num_traits::{Zero, One, Bounded};
|
||||
pub use num_traits::ops::checked::{CheckedAdd, CheckedSub, CheckedMul, CheckedDiv};
|
||||
@@ -160,7 +160,8 @@ pub trait SimpleArithmetic:
|
||||
CheckedSub +
|
||||
CheckedMul +
|
||||
CheckedDiv +
|
||||
PartialOrd<Self> + Ord
|
||||
PartialOrd<Self> + Ord +
|
||||
HasCompact
|
||||
{}
|
||||
impl<T:
|
||||
Zero + One + IntegerSquareRoot + As<u64> +
|
||||
@@ -174,7 +175,8 @@ impl<T:
|
||||
CheckedSub +
|
||||
CheckedMul +
|
||||
CheckedDiv +
|
||||
PartialOrd<Self> + Ord
|
||||
PartialOrd<Self> + Ord +
|
||||
HasCompact
|
||||
> SimpleArithmetic for T {}
|
||||
|
||||
/// Trait for things that can be clear (have no bits set). For numeric types, essentially the same
|
||||
|
||||
@@ -11,7 +11,7 @@ rustc_version = "0.2"
|
||||
wasmi = { version = "0.4.1", optional = true }
|
||||
substrate-primitives = { path = "../primitives", default-features = false }
|
||||
sr-std = { path = "../sr-std", default-features = false }
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
wabt = "0.4"
|
||||
|
||||
@@ -6,8 +6,8 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
[dependencies]
|
||||
serde = { version = "1.0", default-features = false }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec-derive = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
parity-codec-derive = { version = "2.1", default-features = false }
|
||||
sr-std = { path = "../sr-std", default-features = false }
|
||||
|
||||
[features]
|
||||
|
||||
@@ -7,8 +7,8 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
parking_lot = "0.5"
|
||||
log = "0.4"
|
||||
substrate-primitives = { path = "../../core/primitives" }
|
||||
parity-codec = "2.0"
|
||||
parity-codec-derive = "2.0"
|
||||
parity-codec = "2.1"
|
||||
parity-codec-derive = "2.1"
|
||||
|
||||
[dev-dependencies]
|
||||
env_logger = "0.4"
|
||||
|
||||
@@ -14,4 +14,4 @@ trie-db = { git = "https://github.com/paritytech/trie" }
|
||||
trie-root = { git = "https://github.com/paritytech/trie" }
|
||||
substrate-trie = { path = "../trie" }
|
||||
substrate-primitives = { path = "../primitives" }
|
||||
parity-codec = "2.0"
|
||||
parity-codec = "2.1"
|
||||
|
||||
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
|
||||
[dependencies]
|
||||
substrate-client = { path = "../client" }
|
||||
parity-codec = "2.0"
|
||||
parity-codec = "2.1"
|
||||
substrate-executor = { path = "../executor" }
|
||||
substrate-keyring = { path = "../../core/keyring" }
|
||||
substrate-primitives = { path = "../primitives" }
|
||||
|
||||
@@ -8,8 +8,8 @@ log = { version = "0.4", optional = true }
|
||||
hex-literal = { version = "0.1.0", optional = true }
|
||||
serde = { version = "1.0", optional = true }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec-derive = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
parity-codec-derive = { version = "2.1", default-features = false }
|
||||
substrate-keyring = { path = "../keyring", optional = true }
|
||||
substrate-primitives = { path = "../primitives", default-features = false }
|
||||
sr-api = { path = "../sr-api", default-features = false }
|
||||
|
||||
+13
-12
@@ -274,10 +274,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "parity-codec"
|
||||
version = "2.0.2"
|
||||
version = "2.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -468,7 +469,7 @@ dependencies = [
|
||||
name = "sr-api"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 0.1.0",
|
||||
"sr-std 0.1.0",
|
||||
@@ -481,7 +482,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"environmental 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hash-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-std 0.1.0",
|
||||
"substrate-primitives 0.1.0",
|
||||
@@ -496,7 +497,7 @@ dependencies = [
|
||||
"integer-sqrt 0.1.0 (git+https://github.com/paritytech/integer-sqrt-rs.git)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -517,7 +518,7 @@ dependencies = [
|
||||
name = "sr-version"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -530,7 +531,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mashup 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 0.1.0",
|
||||
@@ -548,7 +549,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
name = "substrate-metadata"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -566,7 +567,7 @@ dependencies = [
|
||||
"hash-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"hash256-std-hasher 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -587,7 +588,7 @@ dependencies = [
|
||||
"heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"substrate-primitives 0.1.0",
|
||||
"substrate-trie 0.4.0",
|
||||
@@ -601,7 +602,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-api 0.1.0",
|
||||
"sr-io 0.1.0",
|
||||
@@ -618,7 +619,7 @@ version = "0.4.0"
|
||||
dependencies = [
|
||||
"hash-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"memory-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"trie-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"trie-root 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
]
|
||||
@@ -778,7 +779,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
|
||||
"checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30"
|
||||
"checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37"
|
||||
"checksum parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "df92a55cfa11e8e964e9f0e74b257e21086098d6d3e3fbb2f8fcb17bcbb8e1a1"
|
||||
"checksum parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "dca389ea5e1632c89b2ce54f7e2b4a8a8c9d278042222a91e0bf95451218cb4c"
|
||||
"checksum parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ffa42c2cb493b60b12c75b26e8c94cb734af4df4d7f2cc229dc04c1953dac189"
|
||||
"checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc"
|
||||
"checksum parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "149d8f5b97f3c1133e3cfcd8886449959e856b557ff281e292b733d7c69e005e"
|
||||
|
||||
@@ -6,8 +6,8 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
[dependencies]
|
||||
log = { version = "0.4", optional = true }
|
||||
hex-literal = { version = "0.1.0", optional = true }
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec-derive = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
parity-codec-derive = { version = "2.1", default-features = false }
|
||||
substrate-primitives = { path = "../../primitives", default-features = false }
|
||||
sr-api = { path = "../../sr-api", default-features = false }
|
||||
sr-std = { path = "../../sr-std", default-features = false }
|
||||
|
||||
@@ -7,7 +7,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
error-chain = "0.12"
|
||||
futures = "0.1"
|
||||
log = "0.4"
|
||||
parity-codec = "2.0"
|
||||
parity-codec = "2.1"
|
||||
parking_lot = "0.4"
|
||||
sr-primitives = { path = "../sr-primitives" }
|
||||
substrate-client = { path = "../client" }
|
||||
|
||||
@@ -11,7 +11,7 @@ name = "bench"
|
||||
harness = false
|
||||
|
||||
[dependencies]
|
||||
parity-codec = { version = "2.0" }
|
||||
parity-codec = { version = "2.1" }
|
||||
hash-db = { git = "https://github.com/paritytech/trie", default-features = false }
|
||||
trie-db = { git = "https://github.com/paritytech/trie", optional = true }
|
||||
trie-root = { git = "https://github.com/paritytech/trie", default-features = false }
|
||||
|
||||
@@ -10,7 +10,7 @@ futures = "0.1.17"
|
||||
log = "0.4"
|
||||
node-primitives = { path = "../primitives" }
|
||||
node-runtime = { path = "../runtime" }
|
||||
parity-codec = "2.0"
|
||||
parity-codec = "2.1"
|
||||
parking_lot = "0.4"
|
||||
rhododendron = "0.3"
|
||||
sr-primitives = { path = "../../core/sr-primitives" }
|
||||
|
||||
@@ -7,7 +7,7 @@ description = "Substrate node implementation in Rust."
|
||||
[dependencies]
|
||||
hex-literal = "0.1"
|
||||
trie-root = { git = "https://github.com/paritytech/trie" }
|
||||
parity-codec = "2.0"
|
||||
parity-codec = "2.1"
|
||||
sr-io = { path = "../../core/sr-io" }
|
||||
substrate-state-machine = { path = "../../core/state-machine" }
|
||||
substrate-executor = { path = "../../core/executor" }
|
||||
|
||||
@@ -103,7 +103,7 @@ mod tests {
|
||||
fn xt() -> UncheckedExtrinsic {
|
||||
sign(CheckedExtrinsic {
|
||||
signed: Some((alice(), 0)),
|
||||
function: Call::Balances(balances::Call::transfer::<Runtime>(bob().into(), 69)),
|
||||
function: Call::Balances(balances::Call::transfer::<Runtime>(bob().into(), 69.into())),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -303,11 +303,11 @@ mod tests {
|
||||
vec![
|
||||
CheckedExtrinsic {
|
||||
signed: None,
|
||||
function: Call::Timestamp(timestamp::Call::set(42)),
|
||||
function: Call::Timestamp(timestamp::Call::set(42.into())),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
signed: Some((alice(), 0)),
|
||||
function: Call::Balances(balances::Call::transfer(bob().into(), 69)),
|
||||
function: Call::Balances(balances::Call::transfer(bob().into(), 69.into())),
|
||||
},
|
||||
]
|
||||
)
|
||||
@@ -317,20 +317,20 @@ mod tests {
|
||||
construct_block(
|
||||
2,
|
||||
block1(false).1,
|
||||
hex!("eef4ca8018e0511f89b7cee1e07796aa710a50accc8b1e52082d05cd8c8b6e24").into(),
|
||||
hex!("788a2e8b23e4b30e1bce347ca6415fd0080e989d40741c86995b9ad539bb76b3").into(),
|
||||
None,
|
||||
vec![
|
||||
CheckedExtrinsic {
|
||||
signed: None,
|
||||
function: Call::Timestamp(timestamp::Call::set(52)),
|
||||
function: Call::Timestamp(timestamp::Call::set(52.into())),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
signed: Some((bob(), 0)),
|
||||
function: Call::Balances(balances::Call::transfer(alice().into(), 5)),
|
||||
function: Call::Balances(balances::Call::transfer(alice().into(), 5.into())),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
signed: Some((alice(), 1)),
|
||||
function: Call::Balances(balances::Call::transfer(bob().into(), 15)),
|
||||
function: Call::Balances(balances::Call::transfer(bob().into(), 15.into())),
|
||||
}
|
||||
]
|
||||
)
|
||||
@@ -345,7 +345,7 @@ mod tests {
|
||||
vec![
|
||||
CheckedExtrinsic {
|
||||
signed: None,
|
||||
function: Call::Timestamp(timestamp::Call::set(42)),
|
||||
function: Call::Timestamp(timestamp::Call::set(42.into())),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
signed: Some((alice(), 0)),
|
||||
@@ -627,18 +627,18 @@ mod tests {
|
||||
vec![
|
||||
CheckedExtrinsic {
|
||||
signed: None,
|
||||
function: Call::Timestamp(timestamp::Call::set(42)),
|
||||
function: Call::Timestamp(timestamp::Call::set(42.into())),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
signed: Some((charlie(), 0)),
|
||||
function: Call::Contract(
|
||||
contract::Call::create::<Runtime>(10, 10_000, code_ctor_transfer, Vec::new())
|
||||
contract::Call::create::<Runtime>(10.into(), 10_000.into(), code_ctor_transfer, Vec::new())
|
||||
),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
signed: Some((charlie(), 1)),
|
||||
function: Call::Contract(
|
||||
contract::Call::call::<Runtime>(addr, 10, 10_000, vec![0x00, 0x01, 0x02, 0x03])
|
||||
contract::Call::call::<Runtime>(addr, 10.into(), 10_000.into(), vec![0x00, 0x01, 0x02, 0x03])
|
||||
),
|
||||
},
|
||||
]
|
||||
|
||||
@@ -6,8 +6,8 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
[dependencies]
|
||||
serde = { version = "1.0", default-features = false }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec-derive = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
parity-codec-derive = { version = "2.1", default-features = false }
|
||||
substrate-primitives = { path = "../../core/primitives", default-features = false }
|
||||
sr-std = { path = "../../core/sr-std", default-features = false }
|
||||
sr-primitives = { path = "../../core/sr-primitives", default-features = false }
|
||||
|
||||
@@ -9,8 +9,8 @@ hex-literal = "0.1.0"
|
||||
serde = { version = "1.0", default-features = false }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
safe-mix = { version = "1.0", default-features = false }
|
||||
parity-codec = "2.0"
|
||||
parity-codec-derive = "2.0"
|
||||
parity-codec = "2.1"
|
||||
parity-codec-derive = "2.1"
|
||||
sr-api = { path = "../../core/sr-api", default-features = false }
|
||||
sr-std = { path = "../../core/sr-std" }
|
||||
sr-io = { path = "../../core/sr-io" }
|
||||
|
||||
@@ -284,7 +284,7 @@ impl_apis! {
|
||||
|
||||
fn inherent_extrinsics(data: InherentData) -> Vec<UncheckedExtrinsic> {
|
||||
let mut inherent = vec![generic::UncheckedMortalExtrinsic::new_unsigned(
|
||||
Call::Timestamp(TimestampCall::set(data.timestamp))
|
||||
Call::Timestamp(TimestampCall::set(data.timestamp.into()))
|
||||
)];
|
||||
|
||||
if !data.offline_indices.is_empty() {
|
||||
@@ -307,9 +307,9 @@ impl_apis! {
|
||||
(false, Call::Timestamp(TimestampCall::set(t))) => t,
|
||||
_ => return Err(BlockBuilderError::Generic("No valid timestamp inherent in block".into())),
|
||||
};
|
||||
|
||||
if *t > data.timestamp + MAX_TIMESTAMP_DRIFT {
|
||||
return Err(BlockBuilderError::TimestampInFuture(*t))
|
||||
let t = (*t).into();
|
||||
if t > data.timestamp + MAX_TIMESTAMP_DRIFT {
|
||||
return Err(BlockBuilderError::TimestampInFuture(t))
|
||||
}
|
||||
|
||||
// Offline indices
|
||||
|
||||
Generated
+26
-25
@@ -250,7 +250,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
name = "node-primitives"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -265,7 +265,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"integer-sqrt 0.1.0 (git+https://github.com/paritytech/integer-sqrt-rs.git)",
|
||||
"node-primitives 0.1.0",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-api 0.1.0",
|
||||
@@ -316,10 +316,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "parity-codec"
|
||||
version = "2.0.2"
|
||||
version = "2.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -528,7 +529,7 @@ dependencies = [
|
||||
name = "sr-api"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 0.1.0",
|
||||
"sr-std 0.1.0",
|
||||
@@ -541,7 +542,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"environmental 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hash-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-std 0.1.0",
|
||||
"substrate-primitives 0.1.0",
|
||||
@@ -556,7 +557,7 @@ dependencies = [
|
||||
"integer-sqrt 0.1.0 (git+https://github.com/paritytech/integer-sqrt-rs.git)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -570,7 +571,7 @@ dependencies = [
|
||||
name = "sr-sandbox"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-std 0.1.0",
|
||||
"substrate-primitives 0.1.0",
|
||||
@@ -588,7 +589,7 @@ dependencies = [
|
||||
name = "sr-version"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -600,7 +601,7 @@ name = "srml-balances"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -619,7 +620,7 @@ name = "srml-consensus"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -635,7 +636,7 @@ dependencies = [
|
||||
name = "srml-contract"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pwasm-utils 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -656,7 +657,7 @@ name = "srml-council"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -676,7 +677,7 @@ name = "srml-democracy"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -695,7 +696,7 @@ name = "srml-executive"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -711,7 +712,7 @@ name = "srml-session"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -731,7 +732,7 @@ name = "srml-staking"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -755,7 +756,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mashup 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 0.1.0",
|
||||
@@ -769,7 +770,7 @@ name = "srml-system"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -786,7 +787,7 @@ name = "srml-timestamp"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 0.1.0",
|
||||
@@ -803,7 +804,7 @@ name = "srml-treasury"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -834,7 +835,7 @@ dependencies = [
|
||||
name = "substrate-metadata"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -852,7 +853,7 @@ dependencies = [
|
||||
"hash-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"hash256-std-hasher 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -873,7 +874,7 @@ dependencies = [
|
||||
"heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"substrate-primitives 0.1.0",
|
||||
"substrate-trie 0.4.0",
|
||||
@@ -887,7 +888,7 @@ version = "0.4.0"
|
||||
dependencies = [
|
||||
"hash-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"memory-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"trie-db 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
"trie-root 0.9.0 (git+https://github.com/paritytech/trie)",
|
||||
]
|
||||
@@ -1047,7 +1048,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
|
||||
"checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30"
|
||||
"checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37"
|
||||
"checksum parity-codec 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "df92a55cfa11e8e964e9f0e74b257e21086098d6d3e3fbb2f8fcb17bcbb8e1a1"
|
||||
"checksum parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "dca389ea5e1632c89b2ce54f7e2b4a8a8c9d278042222a91e0bf95451218cb4c"
|
||||
"checksum parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ffa42c2cb493b60b12c75b26e8c94cb734af4df4d7f2cc229dc04c1953dac189"
|
||||
"checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc"
|
||||
"checksum parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "149d8f5b97f3c1133e3cfcd8886449959e856b557ff281e292b733d7c69e005e"
|
||||
|
||||
@@ -9,8 +9,8 @@ crate-type = ["cdylib"]
|
||||
[dependencies]
|
||||
integer-sqrt = { git = "https://github.com/paritytech/integer-sqrt-rs.git", branch = "master" }
|
||||
safe-mix = { version = "1.0", default-features = false}
|
||||
parity-codec-derive = { version = "2.0" }
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec-derive = { version = "2.1" }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
substrate-primitives = { path = "../../../core/primitives", default-features = false }
|
||||
sr-api = { path = "../../../core/sr-api", default-features = false }
|
||||
sr-std = { path = "../../../core/sr-std", default-features = false }
|
||||
|
||||
@@ -13,7 +13,7 @@ node-executor = { path = "../executor" }
|
||||
node-network = { path = "../network" }
|
||||
node-primitives = { path = "../primitives" }
|
||||
node-runtime = { path = "../runtime" }
|
||||
parity-codec = { version = "2.0" }
|
||||
parity-codec = { version = "2.1" }
|
||||
parking_lot = "0.4"
|
||||
slog = "^2"
|
||||
sr-io = { path = "../../core/sr-io" }
|
||||
|
||||
@@ -249,7 +249,7 @@ mod tests {
|
||||
}
|
||||
};
|
||||
let extrinsic_factory = |service: &<Factory as service::ServiceFactory>::FullService| {
|
||||
let payload = (0, Call::Balances(BalancesCall::transfer(RawAddress::Id(bob.public().0.into()), 69)), Era::immortal(), service.client().genesis_hash());
|
||||
let payload = (0, Call::Balances(BalancesCall::transfer(RawAddress::Id(bob.public().0.into()), 69.into())), Era::immortal(), service.client().genesis_hash());
|
||||
let signature = alice.sign(&payload.encode()).into();
|
||||
let id = alice.public().0.into();
|
||||
let xt = UncheckedExtrinsic {
|
||||
|
||||
@@ -8,8 +8,8 @@ hex-literal = "0.1.0"
|
||||
serde = { version = "1.0", default-features = false }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
safe-mix = { version = "1.0", default-features = false}
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec-derive = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
parity-codec-derive = { version = "2.1", default-features = false }
|
||||
substrate-keyring = { path = "../../core/keyring", optional = true }
|
||||
substrate-primitives = { path = "../../core/primitives", default-features = false }
|
||||
sr-std = { path = "../../core/sr-std", default-features = false }
|
||||
|
||||
@@ -41,7 +41,7 @@ extern crate substrate_primitives;
|
||||
|
||||
use rstd::prelude::*;
|
||||
use rstd::{cmp, result};
|
||||
use codec::{Encode, Decode, Codec, Input, Output};
|
||||
use codec::{Encode, Decode, Codec, Input, Output, HasCompact};
|
||||
use runtime_support::{StorageValue, StorageMap, Parameter};
|
||||
use runtime_support::dispatch::Result;
|
||||
use primitives::traits::{Zero, One, SimpleArithmetic, OnFinalise, MakePayment,
|
||||
@@ -125,8 +125,8 @@ pub trait Trait: system::Trait {
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
fn transfer(origin, dest: RawAddress<T::AccountId, T::AccountIndex>, value: T::Balance) -> Result;
|
||||
fn set_balance(who: RawAddress<T::AccountId, T::AccountIndex>, free: T::Balance, reserved: T::Balance) -> Result;
|
||||
fn transfer(origin, dest: RawAddress<T::AccountId, T::AccountIndex>, value: <T::Balance as HasCompact>::Type) -> Result;
|
||||
fn set_balance(who: RawAddress<T::AccountId, T::AccountIndex>, free: <T::Balance as HasCompact>::Type, reserved: <T::Balance as HasCompact>::Type) -> Result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,10 +288,11 @@ impl<T: Trait> Module<T> {
|
||||
// PUBLIC DISPATCH
|
||||
|
||||
/// Transfer some liquid free balance to another staker.
|
||||
pub fn transfer(origin: T::Origin, dest: Address<T>, value: T::Balance) -> Result {
|
||||
pub fn transfer(origin: T::Origin, dest: Address<T>, value: <T::Balance as HasCompact>::Type) -> Result {
|
||||
let transactor = ensure_signed(origin)?;
|
||||
|
||||
let dest = Self::lookup(dest)?;
|
||||
let value = value.into();
|
||||
let from_balance = Self::free_balance(&transactor);
|
||||
let to_balance = Self::free_balance(&dest);
|
||||
let would_create = to_balance.is_zero();
|
||||
@@ -328,10 +329,10 @@ impl<T: Trait> Module<T> {
|
||||
}
|
||||
|
||||
/// Set the balances of a given account.
|
||||
fn set_balance(who: Address<T>, free: T::Balance, reserved: T::Balance) -> Result {
|
||||
fn set_balance(who: Address<T>, free: <T::Balance as HasCompact>::Type, reserved: <T::Balance as HasCompact>::Type) -> Result {
|
||||
let who = Self::lookup(who)?;
|
||||
Self::set_free_balance(&who, free);
|
||||
Self::set_reserved_balance(&who, reserved);
|
||||
Self::set_free_balance(&who, free.into());
|
||||
Self::set_reserved_balance(&who, reserved.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ fn default_indexing_on_new_accounts_should_work() {
|
||||
.build(),
|
||||
|| {
|
||||
assert_eq!(Balances::lookup_index(4), None);
|
||||
assert_ok!(Balances::transfer(Some(1).into(), 5.into(), 10));
|
||||
assert_ok!(Balances::transfer(Some(1).into(), 5.into(), 10.into()));
|
||||
assert_eq!(Balances::lookup_index(4), Some(5));
|
||||
},
|
||||
);
|
||||
@@ -75,7 +75,7 @@ fn default_indexing_on_new_accounts_should_work2() {
|
||||
|| {
|
||||
assert_eq!(Balances::lookup_index(4), None);
|
||||
// account 1 has 256 * 10 = 2560, account 5 is not exist, ext_deposit is 10, value is 10
|
||||
assert_ok!(Balances::transfer(Some(1).into(), 5.into(), 10));
|
||||
assert_ok!(Balances::transfer(Some(1).into(), 5.into(), 10.into()));
|
||||
assert_eq!(Balances::lookup_index(4), Some(5));
|
||||
|
||||
assert_eq!(Balances::free_balance(&1), 256 * 10 - 10 - 50); // 10 is value, 50 is creation_free
|
||||
@@ -95,7 +95,7 @@ fn default_indexing_on_new_accounts_should_not_work2() {
|
||||
assert_eq!(Balances::lookup_index(4), None);
|
||||
// account 1 has 256 * 10 = 2560, account 5 is not exist, ext_deposit is 10, value is 9, not satisfies for ext_deposit
|
||||
assert_noop!(
|
||||
Balances::transfer(Some(1).into(), 5.into(), 9),
|
||||
Balances::transfer(Some(1).into(), 5.into(), 9.into()),
|
||||
"value too low to create account"
|
||||
);
|
||||
assert_eq!(Balances::lookup_index(4), None); // account 5 should not exist
|
||||
@@ -116,7 +116,7 @@ fn dust_account_removal_should_work() {
|
||||
assert_eq!(System::account_nonce(&2), 1);
|
||||
assert_eq!(Balances::total_balance(&2), 256 * 20);
|
||||
|
||||
assert_ok!(Balances::transfer(Some(2).into(), 5.into(), 256 * 10 + 1)); // index 1 (account 2) becomes zombie
|
||||
assert_ok!(Balances::transfer(Some(2).into(), 5.into(), (256 * 10 + 1).into())); // index 1 (account 2) becomes zombie
|
||||
assert_eq!(Balances::total_balance(&2), 0);
|
||||
assert_eq!(Balances::total_balance(&5), 256 * 10 + 1);
|
||||
assert_eq!(System::account_nonce(&2), 0);
|
||||
@@ -136,7 +136,7 @@ fn dust_account_removal_should_work2() {
|
||||
System::inc_account_nonce(&2);
|
||||
assert_eq!(System::account_nonce(&2), 1);
|
||||
assert_eq!(Balances::total_balance(&2), 256 * 20);
|
||||
assert_ok!(Balances::transfer(Some(2).into(), 5.into(), 256 * 10)); // index 1 (account 2) becomes zombie for 256*10 + 50(fee) < 256 * 10 (ext_deposit)
|
||||
assert_ok!(Balances::transfer(Some(2).into(), 5.into(), (256 * 10).into())); // index 1 (account 2) becomes zombie for 256*10 + 50(fee) < 256 * 10 (ext_deposit)
|
||||
assert_eq!(Balances::total_balance(&2), 0);
|
||||
assert_eq!(Balances::total_balance(&5), 256 * 10);
|
||||
assert_eq!(System::account_nonce(&2), 0);
|
||||
@@ -156,10 +156,10 @@ fn reclaim_indexing_on_new_accounts_should_work() {
|
||||
assert_eq!(Balances::lookup_index(4), None);
|
||||
assert_eq!(Balances::total_balance(&2), 256 * 20);
|
||||
|
||||
assert_ok!(Balances::transfer(Some(2).into(), 5.into(), 256 * 20)); // account 2 becomes zombie freeing index 1 for reclaim)
|
||||
assert_ok!(Balances::transfer(Some(2).into(), 5.into(), (256 * 20).into())); // account 2 becomes zombie freeing index 1 for reclaim)
|
||||
assert_eq!(Balances::total_balance(&2), 0);
|
||||
|
||||
assert_ok!(Balances::transfer(Some(5).into(), 6.into(), 256 * 1 + 0x69)); // account 6 takes index 1.
|
||||
assert_ok!(Balances::transfer(Some(5).into(), 6.into(), (256 * 1 + 0x69).into())); // account 6 takes index 1.
|
||||
assert_eq!(Balances::total_balance(&6), 256 * 1 + 0x69);
|
||||
assert_eq!(Balances::lookup_index(1), Some(6));
|
||||
},
|
||||
@@ -178,10 +178,10 @@ fn reclaim_indexing_on_new_accounts_should_work2() {
|
||||
assert_eq!(Balances::lookup_index(4), None);
|
||||
assert_eq!(Balances::total_balance(&2), 256 * 20);
|
||||
|
||||
assert_ok!(Balances::transfer(Some(2).into(), 5.into(), 256 * 20 - 50)); // account 2 becomes zombie freeing index 1 for reclaim) 50 is creation fee
|
||||
assert_ok!(Balances::transfer(Some(2).into(), 5.into(), (256 * 20 - 50).into())); // account 2 becomes zombie freeing index 1 for reclaim) 50 is creation fee
|
||||
assert_eq!(Balances::total_balance(&2), 0);
|
||||
|
||||
assert_ok!(Balances::transfer(Some(5).into(), 6.into(), 256 * 1 + 0x69)); // account 6 takes index 1.
|
||||
assert_ok!(Balances::transfer(Some(5).into(), 6.into(), (256 * 1 + 0x69).into())); // account 6 takes index 1.
|
||||
assert_eq!(Balances::total_balance(&6), 256 * 1 + 0x69);
|
||||
assert_eq!(Balances::lookup_index(1), Some(6));
|
||||
},
|
||||
@@ -206,7 +206,7 @@ fn reserved_balance_should_prevent_reclaim_count() {
|
||||
assert_eq!(Balances::total_balance(&2), 256 * 19 + 1); // reserve still exists.
|
||||
assert_eq!(System::account_nonce(&2), 1);
|
||||
|
||||
assert_ok!(Balances::transfer(Some(4).into(), 5.into(), 256 * 1 + 0x69)); // account 4 tries to take index 1 for account 5.
|
||||
assert_ok!(Balances::transfer(Some(4).into(), 5.into(), (256 * 1 + 0x69).into())); // account 4 tries to take index 1 for account 5.
|
||||
assert_eq!(Balances::total_balance(&5), 256 * 1 + 0x69);
|
||||
assert_eq!(Balances::lookup_index(1), Some(2)); // but fails.
|
||||
assert_eq!(System::account_nonce(&2), 1);
|
||||
@@ -215,7 +215,7 @@ fn reserved_balance_should_prevent_reclaim_count() {
|
||||
assert_eq!(Balances::total_balance(&2), 0); // "free" account deleted."
|
||||
assert_eq!(System::account_nonce(&2), 0);
|
||||
|
||||
assert_ok!(Balances::transfer(Some(4).into(), 6.into(), 256 * 1 + 0x69)); // account 4 tries to take index 1 again for account 6.
|
||||
assert_ok!(Balances::transfer(Some(4).into(), 6.into(), (256 * 1 + 0x69).into())); // account 4 tries to take index 1 again for account 6.
|
||||
assert_eq!(Balances::total_balance(&6), 256 * 1 + 0x69);
|
||||
assert_eq!(Balances::lookup_index(1), Some(6)); // and succeeds.
|
||||
},
|
||||
@@ -240,7 +240,7 @@ fn reserved_balance_should_prevent_reclaim_count2() {
|
||||
assert_eq!(Balances::total_balance(&2), 256 * 19 + 1); // reserve still exists.
|
||||
assert_eq!(System::account_nonce(&2), 1);
|
||||
|
||||
assert_ok!(Balances::transfer(Some(4).into(), 5.into(), 256 * 1 + 0x69)); // account 4 tries to take index 1 for account 5.
|
||||
assert_ok!(Balances::transfer(Some(4).into(), 5.into(), (256 * 1 + 0x69).into())); // account 4 tries to take index 1 for account 5.
|
||||
assert_eq!(Balances::total_balance(&5), 256 * 1 + 0x69);
|
||||
assert_eq!(Balances::lookup_index(1), Some(2)); // but fails.
|
||||
assert_eq!(System::account_nonce(&2), 1);
|
||||
@@ -249,7 +249,7 @@ fn reserved_balance_should_prevent_reclaim_count2() {
|
||||
assert_eq!(Balances::total_balance(&2), 0); // "free" account deleted."
|
||||
assert_eq!(System::account_nonce(&2), 0);
|
||||
|
||||
assert_ok!(Balances::transfer(Some(4).into(), 6.into(), 256 * 1 + 0x69)); // account 4 tries to take index 1 again for account 6.
|
||||
assert_ok!(Balances::transfer(Some(4).into(), 6.into(), (256 * 1 + 0x69).into())); // account 4 tries to take index 1 again for account 6.
|
||||
assert_eq!(Balances::total_balance(&6), 256 * 1 + 0x69);
|
||||
assert_eq!(Balances::lookup_index(1), Some(6)); // and succeeds.
|
||||
},
|
||||
@@ -274,7 +274,7 @@ fn balance_transfer_works() {
|
||||
with_externalities(&mut ExtBuilder::default().build(), || {
|
||||
Balances::set_free_balance(&1, 111);
|
||||
Balances::increase_total_stake_by(111);
|
||||
assert_ok!(Balances::transfer(Some(1).into(), 2.into(), 69));
|
||||
assert_ok!(Balances::transfer(Some(1).into(), 2.into(), 69.into()));
|
||||
assert_eq!(Balances::total_balance(&1), 42);
|
||||
assert_eq!(Balances::total_balance(&2), 69);
|
||||
});
|
||||
@@ -302,7 +302,7 @@ fn balance_transfer_when_reserved_should_not_work() {
|
||||
with_externalities(&mut ExtBuilder::default().build(), || {
|
||||
Balances::set_free_balance(&1, 111);
|
||||
assert_ok!(Balances::reserve(&1, 69));
|
||||
assert_noop!(Balances::transfer(Some(1).into(), 2.into(), 69), "balance too low to send value");
|
||||
assert_noop!(Balances::transfer(Some(1).into(), 2.into(), 69.into()), "balance too low to send value");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -433,7 +433,7 @@ fn transferring_too_high_value_should_not_panic() {
|
||||
<FreeBalance<Runtime>>::insert(2, 1);
|
||||
|
||||
assert_err!(
|
||||
Balances::transfer(Some(1).into(), 2.into(), u64::max_value()),
|
||||
Balances::transfer(Some(1).into(), 2.into(), u64::max_value().into()),
|
||||
"destination balance too high to receive value"
|
||||
);
|
||||
|
||||
@@ -461,7 +461,7 @@ fn account_removal_on_free_too_low() {
|
||||
// Transfer funds from account 1 of such amount that after this transfer
|
||||
// the balance of account 1 will be below the exsistential threshold.
|
||||
// This should lead to the removal of all balance of this account.
|
||||
assert_ok!(Balances::transfer(Some(1).into(), 2.into(), 20));
|
||||
assert_ok!(Balances::transfer(Some(1).into(), 2.into(), 20.into()));
|
||||
|
||||
// Verify free balance removal of account 1.
|
||||
assert_eq!(Balances::free_balance(&1), 0);
|
||||
@@ -481,7 +481,7 @@ fn transfer_overflow_isnt_exploitable() {
|
||||
let evil_value = u64::max_value() - 49;
|
||||
|
||||
assert_err!(
|
||||
Balances::transfer(Some(1).into(), 5.into(), evil_value),
|
||||
Balances::transfer(Some(1).into(), 5.into(), evil_value.into()),
|
||||
"got overflow after adding a fee to value"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
hex-literal = "0.1.0"
|
||||
serde = { version = "1.0", default-features = false }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec-derive = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
parity-codec-derive = { version = "2.1", default-features = false }
|
||||
substrate-primitives = { path = "../../core/primitives", default-features = false }
|
||||
sr-std = { path = "../../core/sr-std", default-features = false }
|
||||
sr-io = { path = "../../core/sr-io", default-features = false }
|
||||
|
||||
@@ -7,8 +7,8 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
serde = { version = "1.0", default-features = false }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
pwasm-utils = { version = "0.3", default-features = false }
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec-derive = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
parity-codec-derive = { version = "2.1", default-features = false }
|
||||
parity-wasm = { version = "0.31", default-features = false }
|
||||
substrate-primitives = { path = "../../core/primitives", default-features = false }
|
||||
sr-primitives = { path = "../../core/sr-primitives", default-features = false }
|
||||
|
||||
@@ -102,7 +102,7 @@ use double_map::StorageDoubleMap;
|
||||
|
||||
use rstd::prelude::*;
|
||||
use rstd::marker::PhantomData;
|
||||
use codec::Codec;
|
||||
use codec::{Codec, HasCompact};
|
||||
use runtime_primitives::traits::{Hash, As, SimpleArithmetic, OnFinalise};
|
||||
use runtime_support::dispatch::Result;
|
||||
use runtime_support::{Parameter, StorageMap, StorageValue};
|
||||
@@ -155,15 +155,15 @@ decl_module! {
|
||||
fn call(
|
||||
origin,
|
||||
dest: T::AccountId,
|
||||
value: T::Balance,
|
||||
gas_limit: T::Gas,
|
||||
value: <T::Balance as HasCompact>::Type,
|
||||
gas_limit: <T::Gas as HasCompact>::Type,
|
||||
data: Vec<u8>
|
||||
) -> Result;
|
||||
|
||||
fn create(
|
||||
origin,
|
||||
value: T::Balance,
|
||||
gas_limit: T::Gas,
|
||||
value: <T::Balance as HasCompact>::Type,
|
||||
gas_limit: <T::Gas as HasCompact>::Type,
|
||||
init_code: Vec<u8>,
|
||||
data: Vec<u8>
|
||||
) -> Result;
|
||||
@@ -227,11 +227,13 @@ impl<T: Trait> Module<T> {
|
||||
fn call(
|
||||
origin: <T as system::Trait>::Origin,
|
||||
dest: T::AccountId,
|
||||
value: T::Balance,
|
||||
gas_limit: T::Gas,
|
||||
value: <T::Balance as HasCompact>::Type,
|
||||
gas_limit: <T::Gas as HasCompact>::Type,
|
||||
data: Vec<u8>,
|
||||
) -> Result {
|
||||
let origin = ensure_signed(origin)?;
|
||||
let value = value.into();
|
||||
let gas_limit = gas_limit.into();
|
||||
|
||||
// Pay for the gas upfront.
|
||||
//
|
||||
@@ -277,12 +279,14 @@ impl<T: Trait> Module<T> {
|
||||
/// upon any message received by this account.
|
||||
fn create(
|
||||
origin: <T as system::Trait>::Origin,
|
||||
endowment: T::Balance,
|
||||
gas_limit: T::Gas,
|
||||
endowment: <T::Balance as HasCompact>::Type,
|
||||
gas_limit: <T::Gas as HasCompact>::Type,
|
||||
ctor_code: Vec<u8>,
|
||||
data: Vec<u8>,
|
||||
) -> Result {
|
||||
let origin = ensure_signed(origin)?;
|
||||
let endowment = endowment.into();
|
||||
let gas_limit = gas_limit.into();
|
||||
|
||||
// Pay for the gas upfront.
|
||||
//
|
||||
|
||||
@@ -199,7 +199,7 @@ fn contract_transfer() {
|
||||
Balances::set_free_balance(&1, 11);
|
||||
Balances::increase_total_stake_by(11);
|
||||
|
||||
assert_ok!(Contract::call(Origin::signed(0), 1, 3, 100_000, Vec::new()));
|
||||
assert_ok!(Contract::call(Origin::signed(0), 1, 3.into(), 100_000.into(), Vec::new()));
|
||||
|
||||
assert_eq!(
|
||||
Balances::free_balance(&0),
|
||||
@@ -257,7 +257,7 @@ fn contract_transfer_to_death() {
|
||||
Balances::increase_total_stake_by(6);
|
||||
<StorageOf<Test>>::insert(1, b"foo".to_vec(), b"1".to_vec());
|
||||
|
||||
assert_ok!(Contract::call(Origin::signed(0), 1, 0, 100_000, Vec::new()));
|
||||
assert_ok!(Contract::call(Origin::signed(0), 1, 0.into(), 100_000.into(), Vec::new()));
|
||||
|
||||
assert_eq!(
|
||||
Balances::free_balance(&0),
|
||||
@@ -290,7 +290,7 @@ fn contract_transfer_takes_creation_fee() {
|
||||
Balances::set_free_balance(&1, 11);
|
||||
Balances::increase_total_stake_by(11);
|
||||
|
||||
assert_ok!(Contract::call(Origin::signed(0), 1, 3, 100_000, Vec::new()));
|
||||
assert_ok!(Contract::call(Origin::signed(0), 1, 3.into(), 100_000.into(), Vec::new()));
|
||||
|
||||
assert_eq!(
|
||||
Balances::free_balance(&0),
|
||||
@@ -331,7 +331,7 @@ fn contract_transfer_takes_transfer_fee() {
|
||||
// is charged (and creation fee is not).
|
||||
Balances::set_free_balance(&CONTRACT_SHOULD_TRANSFER_TO, 25);
|
||||
|
||||
assert_ok!(Contract::call(Origin::signed(0), 1, 3, 100_000, Vec::new()));
|
||||
assert_ok!(Contract::call(Origin::signed(0), 1, 3.into(), 100_000.into(), Vec::new()));
|
||||
|
||||
assert_eq!(
|
||||
Balances::free_balance(&0),
|
||||
@@ -368,7 +368,7 @@ fn contract_transfer_oog() {
|
||||
Balances::set_free_balance(&1, 11);
|
||||
Balances::increase_total_stake_by(11);
|
||||
|
||||
assert_ok!(Contract::call(Origin::signed(0), 1, 3, 135 + 135 + 7, Vec::new()));
|
||||
assert_ok!(Contract::call(Origin::signed(0), 1, 3.into(), (135 + 135 + 7).into(), Vec::new()));
|
||||
|
||||
assert_eq!(
|
||||
Balances::free_balance(&0),
|
||||
@@ -407,7 +407,7 @@ fn contract_transfer_max_depth() {
|
||||
Balances::set_free_balance(&CONTRACT_SHOULD_TRANSFER_TO, 11);
|
||||
Balances::increase_total_stake_by(11);
|
||||
|
||||
assert_ok!(Contract::call(Origin::signed(0), CONTRACT_SHOULD_TRANSFER_TO, 3, 100_000, Vec::new()));
|
||||
assert_ok!(Contract::call(Origin::signed(0), CONTRACT_SHOULD_TRANSFER_TO, 3.into(), 100_000.into(), Vec::new()));
|
||||
|
||||
assert_eq!(
|
||||
Balances::free_balance(&0),
|
||||
@@ -519,7 +519,7 @@ fn contract_create() {
|
||||
<CodeOf<Test>>::insert(1, code_create.to_vec());
|
||||
|
||||
// When invoked, the contract at address `1` must create a contract with 'transfer' code.
|
||||
assert_ok!(Contract::call(Origin::signed(0), 1, 11, 100_000, Vec::new()));
|
||||
assert_ok!(Contract::call(Origin::signed(0), 1, 11.into(), 100_000.into(), Vec::new()));
|
||||
|
||||
let derived_address = <Test as Trait>::DetermineContractAddress::contract_address_for(
|
||||
&code_ctor_transfer,
|
||||
@@ -560,7 +560,7 @@ fn contract_create() {
|
||||
]);
|
||||
|
||||
// Initiate transfer to the newly created contract.
|
||||
assert_ok!(Contract::call(Origin::signed(0), derived_address, 22, 100_000, Vec::new()));
|
||||
assert_ok!(Contract::call(Origin::signed(0), derived_address, 22.into(), 100_000.into(), Vec::new()));
|
||||
|
||||
assert_eq!(
|
||||
Balances::free_balance(&0),
|
||||
@@ -594,8 +594,8 @@ fn top_level_create() {
|
||||
|
||||
assert_ok!(Contract::create(
|
||||
Origin::signed(0),
|
||||
11,
|
||||
100_000,
|
||||
11.into(),
|
||||
100_000.into(),
|
||||
code_ctor_transfer.clone(),
|
||||
Vec::new(),
|
||||
));
|
||||
@@ -639,7 +639,7 @@ fn refunds_unused_gas() {
|
||||
Balances::set_free_balance(&0, 100_000_000);
|
||||
Balances::increase_total_stake_by(100_000_000);
|
||||
|
||||
assert_ok!(Contract::call(Origin::signed(0), 1, 0, 100_000, Vec::new()));
|
||||
assert_ok!(Contract::call(Origin::signed(0), 1, 0.into(), 100_000.into(), Vec::new()));
|
||||
|
||||
assert_eq!(Balances::free_balance(&0), 100_000_000 - 4 - (2 * 135));
|
||||
});
|
||||
@@ -653,7 +653,7 @@ fn call_with_zero_value() {
|
||||
Balances::set_free_balance(&0, 100_000_000);
|
||||
Balances::increase_total_stake_by(100_000_000);
|
||||
|
||||
assert_ok!(Contract::call(Origin::signed(0), 1, 0, 100_000, Vec::new()));
|
||||
assert_ok!(Contract::call(Origin::signed(0), 1, 0.into(), 100_000.into(), Vec::new()));
|
||||
|
||||
assert_eq!(Balances::free_balance(&0), 100_000_000 - (2 * 135));
|
||||
});
|
||||
@@ -667,7 +667,7 @@ fn create_with_zero_endowment() {
|
||||
Balances::set_free_balance(&0, 100_000_000);
|
||||
Balances::increase_total_stake_by(100_000_000);
|
||||
|
||||
assert_ok!(Contract::create(Origin::signed(0), 0, 100_000, code_nop, Vec::new()));
|
||||
assert_ok!(Contract::create(Origin::signed(0), 0.into(), 100_000.into(), code_nop, Vec::new()));
|
||||
|
||||
assert_eq!(
|
||||
Balances::free_balance(&0),
|
||||
@@ -700,7 +700,7 @@ fn account_removal_removes_storage() {
|
||||
// the balance of account 1 is will be below than exsistential threshold.
|
||||
//
|
||||
// This should lead to the removal of all storage associated with this account.
|
||||
assert_ok!(Balances::transfer(Origin::signed(1), 2.into(), 20));
|
||||
assert_ok!(Balances::transfer(Origin::signed(1), 2.into(), 20.into()));
|
||||
|
||||
// Verify that all entries from account 1 is removed, while
|
||||
// entries from account 2 is in place.
|
||||
@@ -740,7 +740,7 @@ fn top_level_call_refunds_even_if_fails() {
|
||||
Balances::increase_total_stake_by(100_000_000);
|
||||
|
||||
assert_err!(
|
||||
Contract::call(Origin::signed(0), 1, 0, 100_000, Vec::new()),
|
||||
Contract::call(Origin::signed(0), 1, 0.into(), 100_000.into(), Vec::new()),
|
||||
"vm execute returned error while call"
|
||||
);
|
||||
|
||||
@@ -773,19 +773,19 @@ fn block_gas_limit() {
|
||||
|
||||
// Spend 50_000 units of gas (OOG).
|
||||
assert_err!(
|
||||
Contract::call(Origin::signed(0), 1, 0, 50_000, Vec::new()),
|
||||
Contract::call(Origin::signed(0), 1, 0.into(), 50_000.into(), Vec::new()),
|
||||
"vm execute returned error while call"
|
||||
);
|
||||
|
||||
// Ensure we can't spend more gas than available in block gas limit.
|
||||
assert_err!(
|
||||
Contract::call(Origin::signed(0), 1, 0, 50_001, Vec::new()),
|
||||
Contract::call(Origin::signed(0), 1, 0.into(), 50_001.into(), Vec::new()),
|
||||
"block gas limit is reached"
|
||||
);
|
||||
|
||||
// However, we can spend another 50_000
|
||||
assert_err!(
|
||||
Contract::call(Origin::signed(0), 1, 0, 50_000, Vec::new()),
|
||||
Contract::call(Origin::signed(0), 1, 0.into(), 50_000.into(), Vec::new()),
|
||||
"vm execute returned error while call"
|
||||
);
|
||||
},
|
||||
@@ -858,7 +858,7 @@ fn input_data() {
|
||||
Balances::set_free_balance(&0, 100_000_000);
|
||||
Balances::increase_total_stake_by(100_000_000);
|
||||
|
||||
assert_ok!(Contract::call(Origin::signed(0), 1, 0, 50_000, vec![0, 1, 2, 3]));
|
||||
assert_ok!(Contract::call(Origin::signed(0), 1, 0.into(), 50_000.into(), vec![0, 1, 2, 3]));
|
||||
|
||||
// all asserts are made within contract code itself.
|
||||
},
|
||||
|
||||
@@ -8,8 +8,8 @@ hex-literal = "0.1.0"
|
||||
serde = { version = "1.0", default-features = false }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
safe-mix = { version = "1.0", default-features = false}
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec-derive = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
parity-codec-derive = { version = "2.1", default-features = false }
|
||||
substrate-primitives = { path = "../../core/primitives", default-features = false }
|
||||
sr-std = { path = "../../core/sr-std", default-features = false }
|
||||
sr-io = { path = "../../core/sr-io", default-features = false }
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
use rstd::prelude::*;
|
||||
use rstd::result;
|
||||
use codec::Compact;
|
||||
use substrate_primitives::u32_trait::Value as U32;
|
||||
use primitives::traits::{Hash, EnsureOrigin, MaybeSerializeDebug, OnFinalise};
|
||||
use srml_support::dispatch::{Result, Dispatchable, Parameter};
|
||||
@@ -67,8 +68,8 @@ decl_event!(
|
||||
decl_module! {
|
||||
#[cfg_attr(feature = "std", serde(bound(deserialize = "<T as Trait>::Proposal: ::serde::de::DeserializeOwned")))]
|
||||
pub struct Module<T: Trait> for enum Call where origin: <T as system::Trait>::Origin {
|
||||
fn propose(origin, threshold: u32, proposal: Box<<T as Trait>::Proposal>) -> Result;
|
||||
fn vote(origin, proposal: T::Hash, index: ProposalIndex, approve: bool) -> Result;
|
||||
fn propose(origin, threshold: Compact<u32>, proposal: Box<<T as Trait>::Proposal>) -> Result;
|
||||
fn vote(origin, proposal: T::Hash, index: Compact<ProposalIndex>, approve: bool) -> Result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,8 +103,9 @@ impl<T: Trait> Module<T> {
|
||||
}
|
||||
|
||||
// Dispatch
|
||||
fn propose(origin: <T as system::Trait>::Origin, threshold: u32, proposal: Box<<T as Trait>::Proposal>) -> Result {
|
||||
fn propose(origin: <T as system::Trait>::Origin, threshold: Compact<u32>, proposal: Box<<T as Trait>::Proposal>) -> Result {
|
||||
let who = ensure_signed(origin)?;
|
||||
let threshold = threshold.into();
|
||||
|
||||
ensure!(Self::is_councillor(&who), "proposer not on council");
|
||||
|
||||
@@ -126,8 +128,9 @@ impl<T: Trait> Module<T> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn vote(origin: <T as system::Trait>::Origin, proposal: T::Hash, index: ProposalIndex, approve: bool) -> Result {
|
||||
fn vote(origin: <T as system::Trait>::Origin, proposal: T::Hash, index: Compact<ProposalIndex>, approve: bool) -> Result {
|
||||
let who = ensure_signed(origin)?;
|
||||
let index = index.into();
|
||||
|
||||
ensure!(Self::is_councillor(&who), "voter not on council");
|
||||
|
||||
@@ -236,7 +239,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn set_balance_proposal(value: u64) -> Call {
|
||||
Call::Balances(balances::Call::set_balance(balances::address::Address::Id(42), value, 0))
|
||||
Call::Balances(balances::Call::set_balance(balances::address::Address::Id(42), value.into(), 0.into()))
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -245,7 +248,7 @@ mod tests {
|
||||
System::set_block_number(1);
|
||||
let proposal = set_balance_proposal(42);
|
||||
let hash = proposal.blake2_256().into();
|
||||
assert_ok!(CouncilMotions::propose(Origin::signed(1), 3, Box::new(proposal.clone())));
|
||||
assert_ok!(CouncilMotions::propose(Origin::signed(1), 3.into(), Box::new(proposal.clone())));
|
||||
assert_eq!(CouncilMotions::proposals(), vec![hash]);
|
||||
assert_eq!(CouncilMotions::proposal_of(&hash), Some(proposal));
|
||||
assert_eq!(CouncilMotions::voting(&hash), Some((0, 3, vec![1], Vec::<u64>::new())));
|
||||
@@ -253,7 +256,7 @@ mod tests {
|
||||
assert_eq!(System::events(), vec![
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: OuterEvent::motions(RawEvent::Proposed(1, 0, hex!["a900ca23832b1f42a5d4af5d0ece88da63fbb4049cc00bac3f741eabb5a79c45"].into(), 3))
|
||||
event: OuterEvent::motions(RawEvent::Proposed(1, 0, hex!["35282aeb9f95795dc1be91b748cec2d210338f2c9c1a85d98e7a3619b6187d22"].into(), 3))
|
||||
}
|
||||
]);
|
||||
});
|
||||
@@ -264,7 +267,7 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(true), || {
|
||||
System::set_block_number(1);
|
||||
let proposal = set_balance_proposal(42);
|
||||
assert_noop!(CouncilMotions::propose(Origin::signed(42), 3, Box::new(proposal.clone())), "proposer not on council");
|
||||
assert_noop!(CouncilMotions::propose(Origin::signed(42), 3.into(), Box::new(proposal.clone())), "proposer not on council");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -274,8 +277,8 @@ mod tests {
|
||||
System::set_block_number(1);
|
||||
let proposal = set_balance_proposal(42);
|
||||
let hash: H256 = proposal.blake2_256().into();
|
||||
assert_ok!(CouncilMotions::propose(Origin::signed(1), 3, Box::new(proposal.clone())));
|
||||
assert_noop!(CouncilMotions::vote(Origin::signed(42), hash.clone(), 0, true), "voter not on council");
|
||||
assert_ok!(CouncilMotions::propose(Origin::signed(1), 3.into(), Box::new(proposal.clone())));
|
||||
assert_noop!(CouncilMotions::vote(Origin::signed(42), hash.clone(), 0.into(), true), "voter not on council");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -285,8 +288,8 @@ mod tests {
|
||||
System::set_block_number(3);
|
||||
let proposal = set_balance_proposal(42);
|
||||
let hash: H256 = proposal.blake2_256().into();
|
||||
assert_ok!(CouncilMotions::propose(Origin::signed(1), 3, Box::new(proposal.clone())));
|
||||
assert_noop!(CouncilMotions::vote(Origin::signed(2), hash.clone(), 1, true), "mismatched index");
|
||||
assert_ok!(CouncilMotions::propose(Origin::signed(1), 3.into(), Box::new(proposal.clone())));
|
||||
assert_noop!(CouncilMotions::vote(Origin::signed(2), hash.clone(), 1.into(), true), "mismatched index");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -296,21 +299,21 @@ mod tests {
|
||||
System::set_block_number(1);
|
||||
let proposal = set_balance_proposal(42);
|
||||
let hash: H256 = proposal.blake2_256().into();
|
||||
assert_ok!(CouncilMotions::propose(Origin::signed(1), 2, Box::new(proposal.clone())));
|
||||
assert_ok!(CouncilMotions::propose(Origin::signed(1), 2.into(), Box::new(proposal.clone())));
|
||||
assert_eq!(CouncilMotions::voting(&hash), Some((0, 2, vec![1], Vec::<u64>::new())));
|
||||
assert_noop!(CouncilMotions::vote(Origin::signed(1), hash.clone(), 0, true), "duplicate vote ignored");
|
||||
assert_ok!(CouncilMotions::vote(Origin::signed(1), hash.clone(), 0, false));
|
||||
assert_noop!(CouncilMotions::vote(Origin::signed(1), hash.clone(), 0.into(), true), "duplicate vote ignored");
|
||||
assert_ok!(CouncilMotions::vote(Origin::signed(1), hash.clone(), 0.into(), false));
|
||||
assert_eq!(CouncilMotions::voting(&hash), Some((0, 2, Vec::<u64>::new(), vec![1])));
|
||||
assert_noop!(CouncilMotions::vote(Origin::signed(1), hash.clone(), 0, false), "duplicate vote ignored");
|
||||
assert_noop!(CouncilMotions::vote(Origin::signed(1), hash.clone(), 0.into(), false), "duplicate vote ignored");
|
||||
|
||||
assert_eq!(System::events(), vec![
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: OuterEvent::motions(RawEvent::Proposed(1, 0, hex!["a900ca23832b1f42a5d4af5d0ece88da63fbb4049cc00bac3f741eabb5a79c45"].into(), 2))
|
||||
event: OuterEvent::motions(RawEvent::Proposed(1, 0, hex!["35282aeb9f95795dc1be91b748cec2d210338f2c9c1a85d98e7a3619b6187d22"].into(), 2))
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: OuterEvent::motions(RawEvent::Voted(1, hex!["a900ca23832b1f42a5d4af5d0ece88da63fbb4049cc00bac3f741eabb5a79c45"].into(), false, 0, 1))
|
||||
event: OuterEvent::motions(RawEvent::Voted(1, hex!["35282aeb9f95795dc1be91b748cec2d210338f2c9c1a85d98e7a3619b6187d22"].into(), false, 0, 1))
|
||||
}
|
||||
]);
|
||||
});
|
||||
@@ -322,21 +325,21 @@ mod tests {
|
||||
System::set_block_number(1);
|
||||
let proposal = set_balance_proposal(42);
|
||||
let hash: H256 = proposal.blake2_256().into();
|
||||
assert_ok!(CouncilMotions::propose(Origin::signed(1), 3, Box::new(proposal.clone())));
|
||||
assert_ok!(CouncilMotions::vote(Origin::signed(2), hash.clone(), 0, false));
|
||||
assert_ok!(CouncilMotions::propose(Origin::signed(1), 3.into(), Box::new(proposal.clone())));
|
||||
assert_ok!(CouncilMotions::vote(Origin::signed(2), hash.clone(), 0.into(), false));
|
||||
|
||||
assert_eq!(System::events(), vec![
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: OuterEvent::motions(RawEvent::Proposed(1, 0, hex!["a900ca23832b1f42a5d4af5d0ece88da63fbb4049cc00bac3f741eabb5a79c45"].into(), 3))
|
||||
event: OuterEvent::motions(RawEvent::Proposed(1, 0, hex!["35282aeb9f95795dc1be91b748cec2d210338f2c9c1a85d98e7a3619b6187d22"].into(), 3))
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: OuterEvent::motions(RawEvent::Voted(2, hex!["a900ca23832b1f42a5d4af5d0ece88da63fbb4049cc00bac3f741eabb5a79c45"].into(), false, 1, 1))
|
||||
event: OuterEvent::motions(RawEvent::Voted(2, hex!["35282aeb9f95795dc1be91b748cec2d210338f2c9c1a85d98e7a3619b6187d22"].into(), false, 1, 1))
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: OuterEvent::motions(RawEvent::Disapproved(hex!["a900ca23832b1f42a5d4af5d0ece88da63fbb4049cc00bac3f741eabb5a79c45"].into()))
|
||||
event: OuterEvent::motions(RawEvent::Disapproved(hex!["35282aeb9f95795dc1be91b748cec2d210338f2c9c1a85d98e7a3619b6187d22"].into()))
|
||||
}
|
||||
]);
|
||||
});
|
||||
@@ -348,25 +351,25 @@ mod tests {
|
||||
System::set_block_number(1);
|
||||
let proposal = set_balance_proposal(42);
|
||||
let hash: H256 = proposal.blake2_256().into();
|
||||
assert_ok!(CouncilMotions::propose(Origin::signed(1), 2, Box::new(proposal.clone())));
|
||||
assert_ok!(CouncilMotions::vote(Origin::signed(2), hash.clone(), 0, true));
|
||||
assert_ok!(CouncilMotions::propose(Origin::signed(1), 2.into(), Box::new(proposal.clone())));
|
||||
assert_ok!(CouncilMotions::vote(Origin::signed(2), hash.clone(), 0.into(), true));
|
||||
|
||||
assert_eq!(System::events(), vec![
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: OuterEvent::motions(RawEvent::Proposed(1, 0, hex!["a900ca23832b1f42a5d4af5d0ece88da63fbb4049cc00bac3f741eabb5a79c45"].into(), 2))
|
||||
event: OuterEvent::motions(RawEvent::Proposed(1, 0, hex!["35282aeb9f95795dc1be91b748cec2d210338f2c9c1a85d98e7a3619b6187d22"].into(), 2))
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: OuterEvent::motions(RawEvent::Voted(2, hex!["a900ca23832b1f42a5d4af5d0ece88da63fbb4049cc00bac3f741eabb5a79c45"].into(), true, 2, 0))
|
||||
event: OuterEvent::motions(RawEvent::Voted(2, hex!["35282aeb9f95795dc1be91b748cec2d210338f2c9c1a85d98e7a3619b6187d22"].into(), true, 2, 0))
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: OuterEvent::motions(RawEvent::Approved(hex!["a900ca23832b1f42a5d4af5d0ece88da63fbb4049cc00bac3f741eabb5a79c45"].into()))
|
||||
event: OuterEvent::motions(RawEvent::Approved(hex!["35282aeb9f95795dc1be91b748cec2d210338f2c9c1a85d98e7a3619b6187d22"].into()))
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: OuterEvent::motions(RawEvent::Executed(hex!["a900ca23832b1f42a5d4af5d0ece88da63fbb4049cc00bac3f741eabb5a79c45"].into(), false))
|
||||
event: OuterEvent::motions(RawEvent::Executed(hex!["35282aeb9f95795dc1be91b748cec2d210338f2c9c1a85d98e7a3619b6187d22"].into(), false))
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
+237
-227
@@ -17,6 +17,7 @@
|
||||
//! Council system: Handles the voting in and maintenance of council members.
|
||||
|
||||
use rstd::prelude::*;
|
||||
use codec::{Compact, HasCompact};
|
||||
use primitives::traits::{Zero, One, As, OnFinalise};
|
||||
use runtime_io::print;
|
||||
use srml_support::{StorageValue, StorageMap, dispatch::Result};
|
||||
@@ -86,16 +87,16 @@ pub trait Trait: democracy::Trait {
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
fn set_approvals(origin, votes: Vec<bool>, index: VoteIndex) -> Result;
|
||||
fn reap_inactive_voter(origin, reporter_index: u32, who: Address<T::AccountId, T::AccountIndex>, who_index: u32, assumed_vote_index: VoteIndex) -> Result;
|
||||
fn retract_voter(origin, index: u32) -> Result;
|
||||
fn submit_candidacy(origin, slot: u32) -> Result;
|
||||
fn present_winner(origin, candidate: Address<T::AccountId, T::AccountIndex>, total: T::Balance, index: VoteIndex) -> Result;
|
||||
fn set_approvals(origin, votes: Vec<bool>, index: Compact<VoteIndex>) -> Result;
|
||||
fn reap_inactive_voter(origin, reporter_index: Compact<u32>, who: Address<T::AccountId, T::AccountIndex>, who_index: Compact<u32>, assumed_vote_index: Compact<VoteIndex>) -> Result;
|
||||
fn retract_voter(origin, index: Compact<u32>) -> Result;
|
||||
fn submit_candidacy(origin, slot: Compact<u32>) -> Result;
|
||||
fn present_winner(origin, candidate: Address<T::AccountId, T::AccountIndex>, total: <T::Balance as HasCompact>::Type, index: Compact<VoteIndex>) -> Result;
|
||||
|
||||
fn set_desired_seats(count: u32) -> Result;
|
||||
fn set_desired_seats(count: Compact<u32>) -> Result;
|
||||
fn remove_member(who: Address<T::AccountId, T::AccountIndex>) -> Result;
|
||||
fn set_presentation_duration(count: T::BlockNumber) -> Result;
|
||||
fn set_term_duration(count: T::BlockNumber) -> Result;
|
||||
fn set_presentation_duration(count: <T::BlockNumber as HasCompact>::Type) -> Result;
|
||||
fn set_term_duration(count: <T::BlockNumber as HasCompact>::Type) -> Result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,8 +228,9 @@ impl<T: Trait> Module<T> {
|
||||
|
||||
/// Set candidate approvals. Approval slots stay valid as long as candidates in those slots
|
||||
/// are registered.
|
||||
fn set_approvals(origin: T::Origin, votes: Vec<bool>, index: VoteIndex) -> Result {
|
||||
fn set_approvals(origin: T::Origin, votes: Vec<bool>, index: Compact<VoteIndex>) -> Result {
|
||||
let who = ensure_signed(origin)?;
|
||||
let index: VoteIndex = index.into();
|
||||
|
||||
ensure!(!Self::presentation_active(), "no approval changes during presentation period");
|
||||
ensure!(index == Self::vote_index(), "incorrect vote index");
|
||||
@@ -255,12 +257,13 @@ impl<T: Trait> Module<T> {
|
||||
/// May be called by anyone. Returns the voter deposit to `signed`.
|
||||
fn reap_inactive_voter(
|
||||
origin: T::Origin,
|
||||
reporter_index: u32,
|
||||
reporter_index: Compact<u32>,
|
||||
who: Address<T::AccountId, T::AccountIndex>,
|
||||
who_index: u32,
|
||||
assumed_vote_index: VoteIndex
|
||||
who_index: Compact<u32>,
|
||||
assumed_vote_index: Compact<VoteIndex>
|
||||
) -> Result {
|
||||
let reporter = ensure_signed(origin)?;
|
||||
let assumed_vote_index: VoteIndex = assumed_vote_index.into();
|
||||
|
||||
let who = <balances::Module<T>>::lookup(who)?;
|
||||
ensure!(!Self::presentation_active(), "cannot reap during presentation period");
|
||||
@@ -269,7 +272,9 @@ impl<T: Trait> Module<T> {
|
||||
ensure!(assumed_vote_index == Self::vote_index(), "vote index not current");
|
||||
ensure!(last_active < assumed_vote_index - Self::inactivity_grace_period(), "cannot reap during grace perid");
|
||||
let voters = Self::voters();
|
||||
let reporter_index: u32 = reporter_index.into();
|
||||
let reporter_index = reporter_index as usize;
|
||||
let who_index: u32 = who_index.into();
|
||||
let who_index = who_index as usize;
|
||||
ensure!(reporter_index < voters.len() && voters[reporter_index] == reporter, "bad reporter index");
|
||||
ensure!(who_index < voters.len() && voters[who_index] == who, "bad target index");
|
||||
@@ -302,12 +307,13 @@ impl<T: Trait> Module<T> {
|
||||
}
|
||||
|
||||
/// Remove a voter. All votes are cancelled and the voter deposit is returned.
|
||||
fn retract_voter(origin: T::Origin, index: u32) -> Result {
|
||||
fn retract_voter(origin: T::Origin, index: Compact<u32>) -> Result {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
ensure!(!Self::presentation_active(), "cannot retract when presenting");
|
||||
ensure!(<LastActiveOf<T>>::exists(&who), "cannot retract non-voter");
|
||||
let voters = Self::voters();
|
||||
let index: u32 = index.into();
|
||||
let index = index as usize;
|
||||
ensure!(index < voters.len(), "retraction index invalid");
|
||||
ensure!(voters[index] == who, "retraction index mismatch");
|
||||
@@ -320,10 +326,11 @@ impl<T: Trait> Module<T> {
|
||||
/// Submit oneself for candidacy.
|
||||
///
|
||||
/// Account must have enough transferrable funds in it to pay the bond.
|
||||
fn submit_candidacy(origin: T::Origin, slot: u32) -> Result {
|
||||
fn submit_candidacy(origin: T::Origin, slot: Compact<u32>) -> Result {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
ensure!(!Self::is_a_candidate(&who), "duplicate candidate submission");
|
||||
let slot: u32 = slot.into();
|
||||
let slot = slot as usize;
|
||||
let count = Self::candidate_count() as usize;
|
||||
let candidates = Self::candidates();
|
||||
@@ -354,10 +361,12 @@ impl<T: Trait> Module<T> {
|
||||
fn present_winner(
|
||||
origin: T::Origin,
|
||||
candidate: Address<T::AccountId, T::AccountIndex>,
|
||||
total: T::Balance,
|
||||
index: VoteIndex
|
||||
total: <T::Balance as HasCompact>::Type,
|
||||
index: Compact<VoteIndex>
|
||||
) -> Result {
|
||||
let who = ensure_signed(origin)?;
|
||||
let total = total.into();
|
||||
let index: VoteIndex = index.into();
|
||||
|
||||
let candidate = <balances::Module<T>>::lookup(candidate)?;
|
||||
ensure!(index == Self::vote_index(), "index not current");
|
||||
@@ -404,7 +413,8 @@ impl<T: Trait> Module<T> {
|
||||
/// Set the desired member count; if lower than the current count, then seats will not be up
|
||||
/// election when they expire. If more, then a new vote will be started if one is not already
|
||||
/// in progress.
|
||||
fn set_desired_seats(count: u32) -> Result {
|
||||
fn set_desired_seats(count: Compact<u32>) -> Result {
|
||||
let count: u32 = count.into();
|
||||
<DesiredSeats<T>>::put(count);
|
||||
Ok(())
|
||||
}
|
||||
@@ -424,15 +434,15 @@ impl<T: Trait> Module<T> {
|
||||
|
||||
/// Set the presentation duration. If there is currently a vote being presented for, will
|
||||
/// invoke `finalise_vote`.
|
||||
fn set_presentation_duration(count: T::BlockNumber) -> Result {
|
||||
<PresentationDuration<T>>::put(count);
|
||||
fn set_presentation_duration(count: <T::BlockNumber as HasCompact>::Type) -> Result {
|
||||
<PresentationDuration<T>>::put(count.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set the presentation duration. If there is current a vote being presented for, will
|
||||
/// invoke `finalise_vote`.
|
||||
fn set_term_duration(count: T::BlockNumber) -> Result {
|
||||
<TermDuration<T>>::put(count);
|
||||
fn set_term_duration(count: <T::BlockNumber as HasCompact>::Type) -> Result {
|
||||
<TermDuration<T>>::put(count.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -606,14 +616,14 @@ mod tests {
|
||||
assert_eq!(Council::is_a_candidate(&1), false);
|
||||
assert_eq!(Council::is_a_candidate(&2), false);
|
||||
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(1), 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(1), 0.into()));
|
||||
assert_eq!(Council::candidates(), vec![1]);
|
||||
assert_eq!(Council::candidate_reg_info(1), Some((0, 0)));
|
||||
assert_eq!(Council::candidate_reg_info(2), None);
|
||||
assert_eq!(Council::is_a_candidate(&1), true);
|
||||
assert_eq!(Council::is_a_candidate(&2), false);
|
||||
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 1));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 1.into()));
|
||||
assert_eq!(Council::candidates(), vec![1, 2]);
|
||||
assert_eq!(Council::candidate_reg_info(1), Some((0, 0)));
|
||||
assert_eq!(Council::candidate_reg_info(2), Some((0, 1)));
|
||||
@@ -640,10 +650,10 @@ mod tests {
|
||||
System::set_block_number(1);
|
||||
assert_eq!(Council::candidates(), vec![0, 0, 1]);
|
||||
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 1));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 1.into()));
|
||||
assert_eq!(Council::candidates(), vec![0, 2, 1]);
|
||||
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 0.into()));
|
||||
assert_eq!(Council::candidates(), vec![3, 2, 1]);
|
||||
});
|
||||
}
|
||||
@@ -656,10 +666,10 @@ mod tests {
|
||||
System::set_block_number(1);
|
||||
assert_eq!(Council::candidates(), vec![0, 0, 1]);
|
||||
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0.into()));
|
||||
assert_eq!(Council::candidates(), vec![2, 0, 1]);
|
||||
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 1));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 1.into()));
|
||||
assert_eq!(Council::candidates(), vec![2, 3, 1]);
|
||||
});
|
||||
}
|
||||
@@ -668,7 +678,7 @@ mod tests {
|
||||
fn candidate_submission_not_using_free_slot_should_not_work() {
|
||||
with_externalities(&mut new_test_ext_with_candidate_holes(), || {
|
||||
System::set_block_number(1);
|
||||
assert_noop!(Council::submit_candidacy(Origin::signed(4), 3), "invalid candidate slot");
|
||||
assert_noop!(Council::submit_candidacy(Origin::signed(4), 3.into()), "invalid candidate slot");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -677,7 +687,7 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(1);
|
||||
assert_eq!(Council::candidates(), Vec::<u64>::new());
|
||||
assert_noop!(Council::submit_candidacy(Origin::signed(1), 1), "invalid candidate slot");
|
||||
assert_noop!(Council::submit_candidacy(Origin::signed(1), 1.into()), "invalid candidate slot");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -686,9 +696,9 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(1);
|
||||
assert_eq!(Council::candidates(), Vec::<u64>::new());
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(1), 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(1), 0.into()));
|
||||
assert_eq!(Council::candidates(), vec![1]);
|
||||
assert_noop!(Council::submit_candidacy(Origin::signed(2), 0), "invalid candidate slot");
|
||||
assert_noop!(Council::submit_candidacy(Origin::signed(2), 0.into()), "invalid candidate slot");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -697,9 +707,9 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(1);
|
||||
assert_eq!(Council::candidates(), Vec::<u64>::new());
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(1), 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(1), 0.into()));
|
||||
assert_eq!(Council::candidates(), vec![1]);
|
||||
assert_noop!(Council::submit_candidacy(Origin::signed(1), 1), "duplicate candidate submission");
|
||||
assert_noop!(Council::submit_candidacy(Origin::signed(1), 1.into()), "duplicate candidate submission");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -708,7 +718,7 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(1);
|
||||
assert_eq!(Council::candidates(), Vec::<u64>::new());
|
||||
assert_noop!(Council::submit_candidacy(Origin::signed(7), 0), "candidate has not enough funds");
|
||||
assert_noop!(Council::submit_candidacy(Origin::signed(7), 0.into()), "candidate has not enough funds");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -717,20 +727,20 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(1);
|
||||
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 0.into()));
|
||||
|
||||
assert_ok!(Council::set_approvals(Origin::signed(1), vec![true], 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(4), vec![true], 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(1), vec![true], 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(4), vec![true], 0.into()));
|
||||
|
||||
assert_eq!(Council::approvals_of(1), vec![true]);
|
||||
assert_eq!(Council::approvals_of(4), vec![true]);
|
||||
assert_eq!(Council::voters(), vec![1, 4]);
|
||||
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 1));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 2));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 1.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 2.into()));
|
||||
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true, true], 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, true, true], 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true, true], 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, true, true], 0.into()));
|
||||
|
||||
assert_eq!(Council::approvals_of(1), vec![true]);
|
||||
assert_eq!(Council::approvals_of(4), vec![true]);
|
||||
@@ -746,14 +756,14 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(1);
|
||||
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(4), vec![true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(4), vec![true], 0.into()));
|
||||
|
||||
assert_eq!(Council::approvals_of(4), vec![true]);
|
||||
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 1));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 2));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(4), vec![true, false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 1.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 2.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(4), vec![true, false, true], 0.into()));
|
||||
|
||||
assert_eq!(Council::approvals_of(4), vec![true, false, true]);
|
||||
});
|
||||
@@ -764,14 +774,14 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(1);
|
||||
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 1));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 2));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 1.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 2.into()));
|
||||
|
||||
assert_ok!(Council::set_approvals(Origin::signed(1), vec![true], 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true, true], 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, true, true], 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(4), vec![true, false, true], 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(1), vec![true], 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true, true], 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, true, true], 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(4), vec![true, false, true], 0.into()));
|
||||
|
||||
assert_eq!(Council::voters(), vec![1, 2, 3, 4]);
|
||||
assert_eq!(Council::approvals_of(1), vec![true]);
|
||||
@@ -779,7 +789,7 @@ mod tests {
|
||||
assert_eq!(Council::approvals_of(3), vec![false, true, true]);
|
||||
assert_eq!(Council::approvals_of(4), vec![true, false, true]);
|
||||
|
||||
assert_ok!(Council::retract_voter(Origin::signed(1), 0));
|
||||
assert_ok!(Council::retract_voter(Origin::signed(1), 0.into()));
|
||||
|
||||
assert_eq!(Council::voters(), vec![4, 2, 3]);
|
||||
assert_eq!(Council::approvals_of(1), Vec::<bool>::new());
|
||||
@@ -787,7 +797,7 @@ mod tests {
|
||||
assert_eq!(Council::approvals_of(3), vec![false, true, true]);
|
||||
assert_eq!(Council::approvals_of(4), vec![true, false, true]);
|
||||
|
||||
assert_ok!(Council::retract_voter(Origin::signed(2), 1));
|
||||
assert_ok!(Council::retract_voter(Origin::signed(2), 1.into()));
|
||||
|
||||
assert_eq!(Council::voters(), vec![4, 3]);
|
||||
assert_eq!(Council::approvals_of(1), Vec::<bool>::new());
|
||||
@@ -795,7 +805,7 @@ mod tests {
|
||||
assert_eq!(Council::approvals_of(3), vec![false, true, true]);
|
||||
assert_eq!(Council::approvals_of(4), vec![true, false, true]);
|
||||
|
||||
assert_ok!(Council::retract_voter(Origin::signed(3), 1));
|
||||
assert_ok!(Council::retract_voter(Origin::signed(3), 1.into()));
|
||||
|
||||
assert_eq!(Council::voters(), vec![4]);
|
||||
assert_eq!(Council::approvals_of(1), Vec::<bool>::new());
|
||||
@@ -809,11 +819,11 @@ mod tests {
|
||||
fn invalid_retraction_index_should_not_work() {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(1);
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(1), vec![true], 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(1), vec![true], 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0.into()));
|
||||
assert_eq!(Council::voters(), vec![1, 2]);
|
||||
assert_noop!(Council::retract_voter(Origin::signed(1), 1), "retraction index mismatch");
|
||||
assert_noop!(Council::retract_voter(Origin::signed(1), 1.into()), "retraction index mismatch");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -821,9 +831,9 @@ mod tests {
|
||||
fn overflow_retraction_index_should_not_work() {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(1);
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(1), vec![true], 0));
|
||||
assert_noop!(Council::retract_voter(Origin::signed(1), 1), "retraction index invalid");
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(1), vec![true], 0.into()));
|
||||
assert_noop!(Council::retract_voter(Origin::signed(1), 1.into()), "retraction index invalid");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -831,9 +841,9 @@ mod tests {
|
||||
fn non_voter_retraction_should_not_work() {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(1);
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(1), vec![true], 0));
|
||||
assert_noop!(Council::retract_voter(Origin::signed(2), 0), "cannot retract non-voter");
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(1), vec![true], 0.into()));
|
||||
assert_noop!(Council::retract_voter(Origin::signed(2), 0.into()), "cannot retract non-voter");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -843,10 +853,10 @@ mod tests {
|
||||
System::set_block_number(4);
|
||||
assert!(!Council::presentation_active());
|
||||
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 1));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false], 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 1.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false], 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true], 0.into()));
|
||||
assert_eq!(Council::voters(), vec![2, 5]);
|
||||
assert_eq!(Council::approvals_of(2), vec![true, false]);
|
||||
assert_eq!(Council::approvals_of(5), vec![false, true]);
|
||||
@@ -854,8 +864,8 @@ mod tests {
|
||||
|
||||
System::set_block_number(6);
|
||||
assert!(Council::presentation_active());
|
||||
assert_eq!(Council::present_winner(Origin::signed(4), 2.into(), 20, 0), Ok(()));
|
||||
assert_eq!(Council::present_winner(Origin::signed(4), 5.into(), 50, 0), Ok(()));
|
||||
assert_eq!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()), Ok(()));
|
||||
assert_eq!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 0.into()), Ok(()));
|
||||
assert_eq!(Council::leaderboard(), Some(vec![(0, 0), (0, 0), (20, 2), (50, 5)]));
|
||||
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
@@ -877,16 +887,16 @@ mod tests {
|
||||
assert!(Balances::can_slash(&4, 10));
|
||||
|
||||
System::set_block_number(4);
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 1));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false], 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 1.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false], 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true], 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50, 0));
|
||||
assert_eq!(Council::present_winner(Origin::signed(4), 5.into(), 50, 0), Err("duplicate presentation"));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 0.into()));
|
||||
assert_eq!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 0.into()), Err("duplicate presentation"));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
assert_eq!(Council::active_council(), vec![(5, 11), (2, 11)]);
|
||||
@@ -898,27 +908,27 @@ mod tests {
|
||||
fn retracting_inactive_voter_should_work() {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(4);
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(8);
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 1));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 1.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(10);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50, 1));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 1.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
assert_ok!(Council::reap_inactive_voter(Origin::signed(5),
|
||||
Council::voters().iter().position(|&i| i == 5).unwrap() as u32,
|
||||
2.into(), Council::voters().iter().position(|&i| i == 2).unwrap() as u32,
|
||||
2
|
||||
(Council::voters().iter().position(|&i| i == 5).unwrap() as u32).into(),
|
||||
2.into(), (Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(),
|
||||
2.into()
|
||||
));
|
||||
|
||||
assert_eq!(Council::voters(), vec![5]);
|
||||
@@ -932,21 +942,21 @@ mod tests {
|
||||
fn presenting_for_double_election_should_not_work() {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(4);
|
||||
assert_eq!(Council::submit_candidacy(Origin::signed(2), 0), Ok(()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0));
|
||||
assert_eq!(Council::submit_candidacy(Origin::signed(2), 0.into()), Ok(()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(8);
|
||||
assert_eq!(Council::submit_candidacy(Origin::signed(2), 0), Ok(()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 1));
|
||||
assert_eq!(Council::submit_candidacy(Origin::signed(2), 0.into()), Ok(()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 1.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(10);
|
||||
assert_noop!(Council::present_winner(Origin::signed(4), 2.into(), 20, 1), "candidate must not form a duplicated member if elected");
|
||||
assert_noop!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 1.into()), "candidate must not form a duplicated member if elected");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -954,30 +964,30 @@ mod tests {
|
||||
fn retracting_inactive_voter_with_other_candidates_in_slots_should_work() {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(4);
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(8);
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 1));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 1.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(10);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50, 1));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 1.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(11);
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(1), 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(1), 0.into()));
|
||||
|
||||
assert_ok!(Council::reap_inactive_voter(Origin::signed(5),
|
||||
Council::voters().iter().position(|&i| i == 5).unwrap() as u32,
|
||||
2.into(), Council::voters().iter().position(|&i| i == 2).unwrap() as u32,
|
||||
2
|
||||
(Council::voters().iter().position(|&i| i == 5).unwrap() as u32).into(),
|
||||
2.into(), (Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(),
|
||||
2.into()
|
||||
));
|
||||
|
||||
assert_eq!(Council::voters(), vec![5]);
|
||||
@@ -991,27 +1001,27 @@ mod tests {
|
||||
fn retracting_inactive_voter_with_bad_reporter_index_should_not_work() {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(4);
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(8);
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 1));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 1.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(10);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50, 1));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 1.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
assert_noop!(Council::reap_inactive_voter(Origin::signed(2),
|
||||
42,
|
||||
2.into(), Council::voters().iter().position(|&i| i == 2).unwrap() as u32,
|
||||
2
|
||||
42.into(),
|
||||
2.into(), (Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(),
|
||||
2.into()
|
||||
), "bad reporter index");
|
||||
});
|
||||
}
|
||||
@@ -1020,27 +1030,27 @@ mod tests {
|
||||
fn retracting_inactive_voter_with_bad_target_index_should_not_work() {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(4);
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(8);
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 1));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 1.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(10);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50, 1));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 1.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
assert_noop!(Council::reap_inactive_voter(Origin::signed(2),
|
||||
Council::voters().iter().position(|&i| i == 2).unwrap() as u32,
|
||||
2.into(), 42,
|
||||
2
|
||||
(Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(),
|
||||
2.into(), 42.into(),
|
||||
2.into()
|
||||
), "bad target index");
|
||||
});
|
||||
}
|
||||
@@ -1049,36 +1059,36 @@ mod tests {
|
||||
fn attempting_to_retract_active_voter_should_slash_reporter() {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(4);
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 1));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(4), 2));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 3));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false, false, false], 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, true, false, false], 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, false, true, false], 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, false, false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 1.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(4), 2.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 3.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false, false, false], 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, true, false, false], 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, false, true, false], 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, false, false, true], 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3.into(), 30, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4.into(), 40, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3.into(), 30.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4.into(), 40.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(8);
|
||||
assert_ok!(Council::set_desired_seats(3));
|
||||
assert_ok!(Council::set_desired_seats(3.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(10);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20, 1));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3.into(), 30, 1));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 1.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3.into(), 30.into(), 1.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
assert_ok!(Council::reap_inactive_voter(Origin::signed(4),
|
||||
Council::voters().iter().position(|&i| i == 4).unwrap() as u32,
|
||||
2.into(), Council::voters().iter().position(|&i| i == 2).unwrap() as u32,
|
||||
2
|
||||
(Council::voters().iter().position(|&i| i == 4).unwrap() as u32).into(),
|
||||
2.into(), (Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(),
|
||||
2.into()
|
||||
));
|
||||
|
||||
assert_eq!(Council::voters(), vec![2, 3, 5]);
|
||||
@@ -1091,27 +1101,27 @@ mod tests {
|
||||
fn attempting_to_retract_inactive_voter_by_nonvoter_should_not_work() {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(4);
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(8);
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 1));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 1.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(10);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50, 1));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 1.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
assert_noop!(Council::reap_inactive_voter(Origin::signed(4),
|
||||
0,
|
||||
2.into(), Council::voters().iter().position(|&i| i == 2).unwrap() as u32,
|
||||
2
|
||||
0.into(),
|
||||
2.into(), (Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(),
|
||||
2.into()
|
||||
), "reporter must be a voter");
|
||||
});
|
||||
}
|
||||
@@ -1120,24 +1130,24 @@ mod tests {
|
||||
fn presenting_loser_should_not_work() {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(4);
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(1), 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(6), vec![true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 1));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 2));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(4), 3));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, false, false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 4));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, false, false, false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(1), 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(6), vec![true], 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 1.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true], 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 2.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, false, true], 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(4), 3.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, false, false, true], 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 4.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, false, false, false, true], 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 1.into(), 60, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3.into(), 30, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4.into(), 40, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50, 0));
|
||||
assert_noop!(Council::present_winner(Origin::signed(4), 2.into(), 20, 0), "candidate not worthy of leaderboard");
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 1.into(), 60.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3.into(), 30.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4.into(), 40.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 0.into()));
|
||||
assert_noop!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()), "candidate not worthy of leaderboard");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1145,24 +1155,24 @@ mod tests {
|
||||
fn presenting_loser_first_should_not_matter() {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(4);
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(1), 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(6), vec![true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 1));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 2));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(4), 3));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, false, false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 4));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, false, false, false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(1), 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(6), vec![true], 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 1.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true], 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 2.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, false, true], 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(4), 3.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, false, false, true], 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 4.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, false, false, false, true], 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 1.into(), 60, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3.into(), 30, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4.into(), 40, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 1.into(), 60.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3.into(), 30.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4.into(), 40.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 0.into()));
|
||||
|
||||
assert_eq!(Council::leaderboard(), Some(vec![
|
||||
(30, 3),
|
||||
@@ -1178,7 +1188,7 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(4);
|
||||
assert!(!Council::presentation_active());
|
||||
assert_noop!(Council::present_winner(Origin::signed(5), 5.into(), 1, 0), "cannot present outside of presentation period");
|
||||
assert_noop!(Council::present_winner(Origin::signed(5), 5.into(), 1.into(), 0.into()), "cannot present outside of presentation period");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1186,14 +1196,14 @@ mod tests {
|
||||
fn present_with_invalid_vote_index_should_not_work() {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(4);
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 1));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false], 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 1.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false], 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true], 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_noop!(Council::present_winner(Origin::signed(4), 2.into(), 20, 1), "index not current");
|
||||
assert_noop!(Council::present_winner(Origin::signed(4), 2.into(), 20.into(), 1.into()), "index not current");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1203,16 +1213,16 @@ mod tests {
|
||||
System::set_block_number(4);
|
||||
assert!(!Council::presentation_active());
|
||||
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(1), 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 1));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false], 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(1), 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 1.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false], 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true], 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_eq!(Balances::free_balance(&1), 1);
|
||||
assert_eq!(Balances::reserved_balance(&1), 9);
|
||||
assert_noop!(Council::present_winner(Origin::signed(1), 1.into(), 20, 0), "presenter must have sufficient slashable funds");
|
||||
assert_noop!(Council::present_winner(Origin::signed(1), 1.into(), 20.into(), 0.into()), "presenter must have sufficient slashable funds");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1223,14 +1233,14 @@ mod tests {
|
||||
assert!(!Council::presentation_active());
|
||||
assert_eq!(Balances::total_balance(&4), 40);
|
||||
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 1));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false], 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 1.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false], 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true], 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_err!(Council::present_winner(Origin::signed(4), 2.into(), 80, 0), "incorrect total");
|
||||
assert_err!(Council::present_winner(Origin::signed(4), 2.into(), 80.into(), 0.into()), "incorrect total");
|
||||
|
||||
assert_eq!(Balances::total_balance(&4), 38);
|
||||
});
|
||||
@@ -1242,31 +1252,31 @@ mod tests {
|
||||
System::set_block_number(4);
|
||||
assert!(!Council::presentation_active());
|
||||
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(1), 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(6), vec![true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 1));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 2));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(4), 3));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, false, false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 4));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, false, false, false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(1), 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(6), vec![true], 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 1.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true], 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 2.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, false, true], 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(4), 3.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, false, false, true], 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 4.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, false, false, false, true], 0.into()));
|
||||
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert!(Council::presentation_active());
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 1.into(), 60, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 1.into(), 60.into(), 0.into()));
|
||||
assert_eq!(Council::leaderboard(), Some(vec![
|
||||
(0, 0),
|
||||
(0, 0),
|
||||
(0, 0),
|
||||
(60, 1)
|
||||
]));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3.into(), 30, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4.into(), 40, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3.into(), 30.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4.into(), 40.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 0.into()));
|
||||
assert_eq!(Council::leaderboard(), Some(vec![
|
||||
(30, 3),
|
||||
(40, 4),
|
||||
@@ -1299,33 +1309,33 @@ mod tests {
|
||||
fn second_tally_should_use_runners_up() {
|
||||
with_externalities(&mut new_test_ext(false), || {
|
||||
System::set_block_number(4);
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(1), 0));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(6), vec![true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 1));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 2));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(4), 3));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, false, false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 4));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, false, false, false, true], 0));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(1), 0.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(6), vec![true], 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(2), 1.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true], 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(3), 2.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, false, true], 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(4), 3.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, false, false, true], 0.into()));
|
||||
assert_ok!(Council::submit_candidacy(Origin::signed(5), 4.into()));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, false, false, false, true], 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(6);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 1.into(), 60, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3.into(), 30, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4.into(), 40, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50, 0));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 1.into(), 60.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3.into(), 30.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4.into(), 40.into(), 0.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 5.into(), 50.into(), 0.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(8);
|
||||
assert_ok!(Council::set_approvals(Origin::signed(6), vec![false, false, true, false], 1));
|
||||
assert_ok!(Council::set_desired_seats(3));
|
||||
assert_ok!(Council::set_approvals(Origin::signed(6), vec![false, false, true, false], 1.into()));
|
||||
assert_ok!(Council::set_desired_seats(3.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
System::set_block_number(10);
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3.into(), 90, 1));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4.into(), 40, 1));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 3.into(), 90.into(), 1.into()));
|
||||
assert_ok!(Council::present_winner(Origin::signed(4), 4.into(), 40.into(), 1.into()));
|
||||
assert_ok!(Council::end_block(System::block_number()));
|
||||
|
||||
assert!(!Council::presentation_active());
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
use rstd::prelude::*;
|
||||
use rstd::borrow::Borrow;
|
||||
use codec::HasCompact;
|
||||
use primitives::traits::{OnFinalise, Hash, As};
|
||||
use runtime_io::print;
|
||||
use srml_support::dispatch::Result;
|
||||
@@ -36,8 +37,8 @@ decl_module! {
|
||||
fn vote(origin, proposal: T::Hash, approve: bool) -> Result;
|
||||
fn veto(origin, proposal_hash: T::Hash) -> Result;
|
||||
|
||||
fn set_cooloff_period(blocks: T::BlockNumber) -> Result;
|
||||
fn set_voting_period(blocks: T::BlockNumber) -> Result;
|
||||
fn set_cooloff_period(blocks: <T::BlockNumber as HasCompact>::Type) -> Result;
|
||||
fn set_voting_period(blocks: <T::BlockNumber as HasCompact>::Type) -> Result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,13 +154,13 @@ impl<T: Trait> Module<T> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_cooloff_period(blocks: T::BlockNumber) -> Result {
|
||||
<CooloffPeriod<T>>::put(blocks);
|
||||
fn set_cooloff_period(blocks: <T::BlockNumber as HasCompact>::Type) -> Result {
|
||||
<CooloffPeriod<T>>::put(blocks.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_voting_period(blocks: T::BlockNumber) -> Result {
|
||||
<VotingPeriod<T>>::put(blocks);
|
||||
fn set_voting_period(blocks: <T::BlockNumber as HasCompact>::Type) -> Result {
|
||||
<VotingPeriod<T>>::put(blocks.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -209,7 +210,7 @@ impl<T: Trait> Module<T> {
|
||||
if let Some(&democracy::Call::cancel_referendum(ref_index)) = IsSubType::<democracy::Module<T>>::is_aux_sub_type(&proposal) {
|
||||
Self::deposit_event(RawEvent::TallyCancelation(proposal_hash, tally.0, tally.1, tally.2));
|
||||
if let (_, 0, 0) = tally {
|
||||
<democracy::Module<T>>::internal_cancel_referendum(ref_index);
|
||||
<democracy::Module<T>>::internal_cancel_referendum(ref_index.into());
|
||||
}
|
||||
} else {
|
||||
Self::deposit_event(RawEvent::TallyReferendum(proposal_hash.clone(), tally.0, tally.1, tally.2));
|
||||
@@ -264,11 +265,11 @@ mod tests {
|
||||
}
|
||||
|
||||
fn set_balance_proposal(value: u64) -> Call {
|
||||
Call::Balances(balances::Call::set_balance(balances::address::Address::Id(42), value, 0))
|
||||
Call::Balances(balances::Call::set_balance(balances::address::Address::Id(42), value.into(), 0.into()))
|
||||
}
|
||||
|
||||
fn cancel_referendum_proposal(id: u32) -> Call {
|
||||
Call::Democracy(democracy::Call::cancel_referendum(id))
|
||||
Call::Democracy(democracy::Call::cancel_referendum(id.into()))
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -8,8 +8,8 @@ hex-literal = "0.1.0"
|
||||
serde = { version = "1.0", default-features = false }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
safe-mix = { version = "1.0", default-features = false}
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec-derive = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
parity-codec-derive = { version = "2.1", default-features = false }
|
||||
substrate-primitives = { path = "../../core/primitives", default-features = false }
|
||||
sr-std = { path = "../../core/sr-std", default-features = false }
|
||||
sr-io = { path = "../../core/sr-io", default-features = false }
|
||||
|
||||
@@ -40,6 +40,7 @@ extern crate srml_system as system;
|
||||
|
||||
use rstd::prelude::*;
|
||||
use rstd::result;
|
||||
use codec::{HasCompact, Compact};
|
||||
use primitives::traits::{Zero, OnFinalise, As, MaybeSerializeDebug};
|
||||
use srml_support::{StorageValue, StorageMap, Parameter, Dispatchable, IsSubType};
|
||||
use srml_support::dispatch::Result;
|
||||
@@ -61,12 +62,12 @@ pub trait Trait: balances::Trait + Sized {
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
fn propose(origin, proposal: Box<T::Proposal>, value: T::Balance) -> Result;
|
||||
fn second(origin, proposal: PropIndex) -> Result;
|
||||
fn vote(origin, ref_index: ReferendumIndex, approve_proposal: bool) -> Result;
|
||||
fn propose(origin, proposal: Box<T::Proposal>, value: <T::Balance as HasCompact>::Type) -> Result;
|
||||
fn second(origin, proposal: Compact<PropIndex>) -> Result;
|
||||
fn vote(origin, ref_index: Compact<ReferendumIndex>, approve_proposal: bool) -> Result;
|
||||
|
||||
fn start_referendum(proposal: Box<T::Proposal>, vote_threshold: VoteThreshold) -> Result;
|
||||
fn cancel_referendum(ref_index: ReferendumIndex) -> Result;
|
||||
fn cancel_referendum(ref_index: Compact<ReferendumIndex>) -> Result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,8 +165,10 @@ impl<T: Trait> Module<T> {
|
||||
// dispatching.
|
||||
|
||||
/// Propose a sensitive action to be taken.
|
||||
fn propose(origin: T::Origin, proposal: Box<T::Proposal>, value: T::Balance) -> Result {
|
||||
fn propose(origin: T::Origin, proposal: Box<T::Proposal>, value: <T::Balance as HasCompact>::Type) -> Result {
|
||||
let who = ensure_signed(origin)?;
|
||||
let value = value.into();
|
||||
|
||||
ensure!(value >= Self::minimum_deposit(), "value too low");
|
||||
<balances::Module<T>>::reserve(&who, value)
|
||||
.map_err(|_| "proposer's balance too low")?;
|
||||
@@ -181,8 +184,9 @@ impl<T: Trait> Module<T> {
|
||||
}
|
||||
|
||||
/// Propose a sensitive action to be taken.
|
||||
fn second(origin: T::Origin, proposal: PropIndex) -> Result {
|
||||
fn second(origin: T::Origin, proposal: Compact<PropIndex>) -> Result {
|
||||
let who = ensure_signed(origin)?;
|
||||
let proposal: PropIndex = proposal.into();
|
||||
let mut deposit = Self::deposit_of(proposal)
|
||||
.ok_or("can only second an existing proposal")?;
|
||||
<balances::Module<T>>::reserve(&who, deposit.0)
|
||||
@@ -194,8 +198,9 @@ impl<T: Trait> Module<T> {
|
||||
|
||||
/// Vote in a referendum. If `approve_proposal` is true, the vote is to enact the proposal;
|
||||
/// false would be a vote to keep the status quo.
|
||||
fn vote(origin: T::Origin, ref_index: ReferendumIndex, approve_proposal: bool) -> Result {
|
||||
fn vote(origin: T::Origin, ref_index: Compact<ReferendumIndex>, approve_proposal: bool) -> Result {
|
||||
let who = ensure_signed(origin)?;
|
||||
let ref_index = ref_index.into();
|
||||
ensure!(Self::is_active_referendum(ref_index), "vote given for invalid referendum.");
|
||||
ensure!(!<balances::Module<T>>::total_balance(&who).is_zero(),
|
||||
"transactor must have balance to signal approval.");
|
||||
@@ -216,8 +221,8 @@ impl<T: Trait> Module<T> {
|
||||
}
|
||||
|
||||
/// Remove a referendum.
|
||||
fn cancel_referendum(ref_index: ReferendumIndex) -> Result {
|
||||
Self::clear_referendum(ref_index);
|
||||
fn cancel_referendum(ref_index: Compact<ReferendumIndex>) -> Result {
|
||||
Self::clear_referendum(ref_index.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -394,11 +399,11 @@ mod tests {
|
||||
}
|
||||
|
||||
fn set_balance_proposal(value: u64) -> Call {
|
||||
Call::Balances(balances::Call::set_balance(balances::address::Address::Id(42), value, 0))
|
||||
Call::Balances(balances::Call::set_balance(balances::address::Address::Id(42), value.into(), 0.into()))
|
||||
}
|
||||
|
||||
fn propose_set_balance(who: u64, value: u64, locked: u64) -> super::Result {
|
||||
Democracy::propose(Origin::signed(who), Box::new(set_balance_proposal(value)), locked)
|
||||
Democracy::propose(Origin::signed(who), Box::new(set_balance_proposal(value)), locked.into())
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -423,7 +428,7 @@ mod tests {
|
||||
|
||||
System::set_block_number(2);
|
||||
let r = 0;
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, true));
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r.into(), true));
|
||||
|
||||
assert_eq!(Democracy::referendum_count(), 1);
|
||||
assert_eq!(Democracy::voters_for(r), vec![1]);
|
||||
@@ -441,10 +446,10 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
System::set_block_number(1);
|
||||
assert_ok!(propose_set_balance(1, 2, 5));
|
||||
assert_ok!(Democracy::second(Origin::signed(2), 0));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0));
|
||||
assert_ok!(Democracy::second(Origin::signed(2), 0.into()));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0.into()));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0.into()));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0.into()));
|
||||
assert_eq!(Balances::free_balance(&1), 5);
|
||||
assert_eq!(Balances::free_balance(&2), 15);
|
||||
assert_eq!(Balances::free_balance(&5), 35);
|
||||
@@ -456,10 +461,10 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
System::set_block_number(1);
|
||||
assert_ok!(propose_set_balance(1, 2, 5));
|
||||
assert_ok!(Democracy::second(Origin::signed(2), 0));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0));
|
||||
assert_ok!(Democracy::second(Origin::signed(2), 0.into()));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0.into()));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0.into()));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0.into()));
|
||||
assert_eq!(Democracy::end_block(System::block_number()), Ok(()));
|
||||
assert_eq!(Balances::free_balance(&1), 10);
|
||||
assert_eq!(Balances::free_balance(&2), 20);
|
||||
@@ -488,7 +493,7 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
System::set_block_number(1);
|
||||
assert_ok!(propose_set_balance(2, 2, 11));
|
||||
assert_noop!(Democracy::second(Origin::signed(1), 0), "seconder\'s balance too low");
|
||||
assert_noop!(Democracy::second(Origin::signed(1), 0.into()), "seconder\'s balance too low");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -502,17 +507,17 @@ mod tests {
|
||||
assert_eq!(Democracy::end_block(System::block_number()), Ok(()));
|
||||
|
||||
System::set_block_number(1);
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), 0, true));
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), 0.into(), true));
|
||||
assert_eq!(Democracy::end_block(System::block_number()), Ok(()));
|
||||
assert_eq!(Balances::free_balance(&42), 4);
|
||||
|
||||
System::set_block_number(2);
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), 1, true));
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), 1.into(), true));
|
||||
assert_eq!(Democracy::end_block(System::block_number()), Ok(()));
|
||||
assert_eq!(Balances::free_balance(&42), 3);
|
||||
|
||||
System::set_block_number(3);
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), 2, true));
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), 2.into(), true));
|
||||
assert_eq!(Democracy::end_block(System::block_number()), Ok(()));
|
||||
});
|
||||
}
|
||||
@@ -522,7 +527,7 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
System::set_block_number(1);
|
||||
let r = Democracy::inject_referendum(1, set_balance_proposal(2), VoteThreshold::SuperMajorityApprove).unwrap();
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, true));
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r.into(), true));
|
||||
|
||||
assert_eq!(Democracy::voters_for(r), vec![1]);
|
||||
assert_eq!(Democracy::vote_of((r, 1)), Some(true));
|
||||
@@ -539,8 +544,8 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
System::set_block_number(1);
|
||||
let r = Democracy::inject_referendum(1, set_balance_proposal(2), VoteThreshold::SuperMajorityApprove).unwrap();
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, true));
|
||||
assert_ok!(Democracy::cancel_referendum(r));
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r.into(), true));
|
||||
assert_ok!(Democracy::cancel_referendum(r.into()));
|
||||
|
||||
assert_eq!(Democracy::end_block(System::block_number()), Ok(()));
|
||||
|
||||
@@ -553,7 +558,7 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
System::set_block_number(1);
|
||||
let r = Democracy::inject_referendum(1, set_balance_proposal(2), VoteThreshold::SuperMajorityApprove).unwrap();
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, false));
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r.into(), false));
|
||||
|
||||
assert_eq!(Democracy::voters_for(r), vec![1]);
|
||||
assert_eq!(Democracy::vote_of((r, 1)), Some(false));
|
||||
@@ -570,12 +575,12 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
System::set_block_number(1);
|
||||
let r = Democracy::inject_referendum(1, set_balance_proposal(2), VoteThreshold::SuperMajorityApprove).unwrap();
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, true));
|
||||
assert_ok!(Democracy::vote(Origin::signed(2), r, false));
|
||||
assert_ok!(Democracy::vote(Origin::signed(3), r, false));
|
||||
assert_ok!(Democracy::vote(Origin::signed(4), r, true));
|
||||
assert_ok!(Democracy::vote(Origin::signed(5), r, false));
|
||||
assert_ok!(Democracy::vote(Origin::signed(6), r, true));
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r.into(), true));
|
||||
assert_ok!(Democracy::vote(Origin::signed(2), r.into(), false));
|
||||
assert_ok!(Democracy::vote(Origin::signed(3), r.into(), false));
|
||||
assert_ok!(Democracy::vote(Origin::signed(4), r.into(), true));
|
||||
assert_ok!(Democracy::vote(Origin::signed(5), r.into(), false));
|
||||
assert_ok!(Democracy::vote(Origin::signed(6), r.into(), true));
|
||||
|
||||
assert_eq!(Democracy::tally(r), (110, 100));
|
||||
|
||||
@@ -590,8 +595,8 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
System::set_block_number(1);
|
||||
let r = Democracy::inject_referendum(1, set_balance_proposal(2), VoteThreshold::SuperMajorityApprove).unwrap();
|
||||
assert_ok!(Democracy::vote(Origin::signed(5), r, false));
|
||||
assert_ok!(Democracy::vote(Origin::signed(6), r, true));
|
||||
assert_ok!(Democracy::vote(Origin::signed(5), r.into(), false));
|
||||
assert_ok!(Democracy::vote(Origin::signed(6), r.into(), true));
|
||||
|
||||
assert_eq!(Democracy::tally(r), (60, 50));
|
||||
|
||||
@@ -609,9 +614,9 @@ mod tests {
|
||||
|
||||
System::set_block_number(1);
|
||||
let r = Democracy::inject_referendum(1, set_balance_proposal(2), VoteThreshold::SuperMajorityApprove).unwrap();
|
||||
assert_ok!(Democracy::vote(Origin::signed(4), r, true));
|
||||
assert_ok!(Democracy::vote(Origin::signed(5), r, false));
|
||||
assert_ok!(Democracy::vote(Origin::signed(6), r, true));
|
||||
assert_ok!(Democracy::vote(Origin::signed(4), r.into(), true));
|
||||
assert_ok!(Democracy::vote(Origin::signed(5), r.into(), false));
|
||||
assert_ok!(Democracy::vote(Origin::signed(6), r.into(), true));
|
||||
|
||||
assert_eq!(Democracy::tally(r), (100, 50));
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
hex-literal = "0.1.0"
|
||||
serde = { version = "1.0", default-features = false }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec-derive = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
parity-codec-derive = { version = "2.1", default-features = false }
|
||||
substrate-primitives = { path = "../../core/primitives", default-features = false }
|
||||
sr-std = { path = "../../core/sr-std", default-features = false }
|
||||
sr-io = { path = "../../core/sr-io", default-features = false }
|
||||
|
||||
@@ -109,8 +109,6 @@ decl_module! {
|
||||
/// world.
|
||||
fn accumulate_dummy(origin, increase_by: T::Balance) -> Result;
|
||||
|
||||
fn accumulate_foo(origin, increase_by: T::Balance) -> Result;
|
||||
|
||||
/// A privileged call; in this case it resets our dummy value to something new.
|
||||
fn set_dummy(new_dummy: T::Balance) -> Result;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
hex-literal = "0.1.0"
|
||||
serde = { version = "1.0", default-features = false }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec-derive = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
parity-codec-derive = { version = "2.1", default-features = false }
|
||||
sr-std = { path = "../../core/sr-std", default-features = false }
|
||||
sr-io = { path = "../../core/sr-io", default-features = false }
|
||||
sr-primitives = { path = "../../core/sr-primitives", default-features = false }
|
||||
|
||||
@@ -332,7 +332,7 @@ mod tests {
|
||||
creation_fee: 0,
|
||||
reclaim_rebate: 0,
|
||||
}.build_storage().unwrap());
|
||||
let xt = primitives::testing::TestXt(Some(1), 0, Call::transfer(2.into(), 69));
|
||||
let xt = primitives::testing::TestXt(Some(1), 0, Call::transfer(2.into(), 69.into()));
|
||||
let mut t = runtime_io::TestExternalities::<Blake2Hasher>::new(t);
|
||||
with_externalities(&mut t, || {
|
||||
Executive::initialise_block(&Header::new(1, H256::default(), H256::default(),
|
||||
@@ -402,7 +402,7 @@ mod tests {
|
||||
#[test]
|
||||
fn bad_extrinsic_not_inserted() {
|
||||
let mut t = new_test_ext();
|
||||
let xt = primitives::testing::TestXt(Some(1), 42, Call::transfer(33.into(), 69));
|
||||
let xt = primitives::testing::TestXt(Some(1), 42, Call::transfer(33.into(), 69.into()));
|
||||
with_externalities(&mut t, || {
|
||||
Executive::initialise_block(&Header::new(1, H256::default(), H256::default(), [69u8; 32].into(), Digest::default()));
|
||||
assert!(Executive::apply_extrinsic(xt).is_err());
|
||||
|
||||
@@ -4,8 +4,8 @@ version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
|
||||
[dependencies]
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec-derive = { version = "^2.0.1", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
parity-codec-derive = { version = "2.1", default-features = false }
|
||||
serde = { version = "1.0", optional = true }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ serde = { version = "1.0", default-features = false }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
safe-mix = { version = "1.0", default-features = false}
|
||||
substrate-primitives = { path = "../../core/primitives", default-features = false }
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec-derive = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
parity-codec-derive = { version = "2.1", default-features = false }
|
||||
sr-std = { path = "../../core/sr-std", default-features = false }
|
||||
sr-io = { path = "../../core/sr-io", default-features = false }
|
||||
sr-primitives = { path = "../../core/sr-primitives", default-features = false }
|
||||
|
||||
@@ -43,6 +43,7 @@ extern crate srml_timestamp as timestamp;
|
||||
|
||||
use rstd::prelude::*;
|
||||
use primitives::traits::{As, Zero, One, OnFinalise, Convert};
|
||||
use codec::HasCompact;
|
||||
use runtime_support::{StorageValue, StorageMap};
|
||||
use runtime_support::dispatch::Result;
|
||||
use system::ensure_signed;
|
||||
@@ -68,7 +69,7 @@ decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
fn set_key(origin, key: T::SessionKey) -> Result;
|
||||
|
||||
fn set_length(new: T::BlockNumber) -> Result;
|
||||
fn set_length(new: <T::BlockNumber as HasCompact>::Type) -> Result;
|
||||
fn force_new_session(apply_rewards: bool) -> Result;
|
||||
}
|
||||
}
|
||||
@@ -133,8 +134,8 @@ impl<T: Trait> Module<T> {
|
||||
}
|
||||
|
||||
/// Set a new session length. Won't kick in until the next session change (at current length).
|
||||
fn set_length(new: T::BlockNumber) -> Result {
|
||||
<NextSessionLength<T>>::put(new);
|
||||
fn set_length(new: <T::BlockNumber as HasCompact>::Type) -> Result {
|
||||
<NextSessionLength<T>>::put(new.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -309,7 +310,7 @@ mod tests {
|
||||
fn should_work_with_early_exit() {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
System::set_block_number(1);
|
||||
assert_ok!(Session::set_length(10));
|
||||
assert_ok!(Session::set_length(10.into()));
|
||||
assert_eq!(Session::blocks_remaining(), 1);
|
||||
Session::check_rotate_session(1);
|
||||
|
||||
@@ -344,14 +345,14 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
// Block 1: Change to length 3; no visible change.
|
||||
System::set_block_number(1);
|
||||
assert_ok!(Session::set_length(3));
|
||||
assert_ok!(Session::set_length(3.into()));
|
||||
Session::check_rotate_session(1);
|
||||
assert_eq!(Session::length(), 2);
|
||||
assert_eq!(Session::current_index(), 0);
|
||||
|
||||
// Block 2: Length now changed to 3. Index incremented.
|
||||
System::set_block_number(2);
|
||||
assert_ok!(Session::set_length(3));
|
||||
assert_ok!(Session::set_length(3.into()));
|
||||
Session::check_rotate_session(2);
|
||||
assert_eq!(Session::length(), 3);
|
||||
assert_eq!(Session::current_index(), 1);
|
||||
@@ -364,7 +365,7 @@ mod tests {
|
||||
|
||||
// Block 4: Change to length 2; no visible change.
|
||||
System::set_block_number(4);
|
||||
assert_ok!(Session::set_length(2));
|
||||
assert_ok!(Session::set_length(2.into()));
|
||||
Session::check_rotate_session(4);
|
||||
assert_eq!(Session::length(), 3);
|
||||
assert_eq!(Session::current_index(), 1);
|
||||
|
||||
@@ -8,8 +8,8 @@ hex-literal = "0.1.0"
|
||||
serde = { version = "1.0", default-features = false }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
safe-mix = { version = "1.0", default-features = false}
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec-derive = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
parity-codec-derive = { version = "2.1", default-features = false }
|
||||
substrate-keyring = { path = "../../core/keyring", optional = true }
|
||||
substrate-primitives = { path = "../../core/primitives", default-features = false }
|
||||
sr-std = { path = "../../core/sr-std", default-features = false }
|
||||
|
||||
@@ -51,6 +51,7 @@ extern crate srml_timestamp as timestamp;
|
||||
|
||||
use rstd::prelude::*;
|
||||
use rstd::cmp;
|
||||
use codec::{HasCompact, Compact};
|
||||
use runtime_support::{Parameter, StorageValue, StorageMap};
|
||||
use runtime_support::dispatch::Result;
|
||||
use session::OnSessionChange;
|
||||
@@ -75,14 +76,16 @@ pub enum LockStatus<BlockNumber: Parameter> {
|
||||
/// Preference of what happens on a slash event.
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
|
||||
pub struct ValidatorPrefs<Balance> {
|
||||
pub struct ValidatorPrefs<Balance: HasCompact + Copy> { // TODO: @bkchr shouldn't need this Copy but derive(Encode) breaks otherwise
|
||||
/// Validator should ensure this many more slashes than is necessary before being unstaked.
|
||||
#[codec(compact)]
|
||||
pub unstake_threshold: u32,
|
||||
// Reward that validator takes up-front; only the rest is split between themselves and nominators.
|
||||
#[codec(encoded_as = "<Balance as HasCompact>::Type")]
|
||||
pub validator_payment: Balance,
|
||||
}
|
||||
|
||||
impl<B: Default> Default for ValidatorPrefs<B> {
|
||||
impl<B: Default + HasCompact + Copy> Default for ValidatorPrefs<B> {
|
||||
fn default() -> Self {
|
||||
ValidatorPrefs {
|
||||
unstake_threshold: 3,
|
||||
@@ -103,16 +106,16 @@ decl_module! {
|
||||
#[cfg_attr(feature = "std", serde(bound(deserialize = "T::Balance: ::serde::de::DeserializeOwned")))]
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
fn stake(origin) -> Result;
|
||||
fn unstake(origin, intentions_index: u32) -> Result;
|
||||
fn unstake(origin, intentions_index: Compact<u32>) -> Result;
|
||||
fn nominate(origin, target: Address<T::AccountId, T::AccountIndex>) -> Result;
|
||||
fn unnominate(origin, target_index: u32) -> Result;
|
||||
fn register_preferences(origin, intentions_index: u32, prefs: ValidatorPrefs<T::Balance>) -> Result;
|
||||
fn unnominate(origin, target_index: Compact<u32>) -> Result;
|
||||
fn register_preferences(origin, intentions_index: Compact<u32>, prefs: ValidatorPrefs<T::Balance>) -> Result;
|
||||
|
||||
fn set_sessions_per_era(new: T::BlockNumber) -> Result;
|
||||
fn set_bonding_duration(new: T::BlockNumber) -> Result;
|
||||
fn set_validator_count(new: u32) -> Result;
|
||||
fn set_sessions_per_era(new: <T::BlockNumber as HasCompact>::Type) -> Result;
|
||||
fn set_bonding_duration(new: <T::BlockNumber as HasCompact>::Type) -> Result;
|
||||
fn set_validator_count(new: Compact<u32>) -> Result;
|
||||
fn force_new_era(apply_rewards: bool) -> Result;
|
||||
fn set_offline_slash_grace(new: u32) -> Result;
|
||||
fn set_offline_slash_grace(new: Compact<u32>) -> Result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,8 +246,9 @@ impl<T: Trait> Module<T> {
|
||||
/// Retract the desire to stake for the transactor.
|
||||
///
|
||||
/// Effects will be felt at the beginning of the next era.
|
||||
fn unstake(origin: T::Origin, intentions_index: u32) -> Result {
|
||||
fn unstake(origin: T::Origin, intentions_index: Compact<u32>) -> Result {
|
||||
let who = ensure_signed(origin)?;
|
||||
let intentions_index: u32 = intentions_index.into();
|
||||
// unstake fails in degenerate case of having too few existing staked parties
|
||||
if Self::intentions().len() <= Self::minimum_validator_count() as usize {
|
||||
return Err("cannot unstake when there are too few staked participants")
|
||||
@@ -275,8 +279,9 @@ impl<T: Trait> Module<T> {
|
||||
|
||||
/// Will panic if called when source isn't currently nominating target.
|
||||
/// Updates Nominating, NominatorsFor and NominationBalance.
|
||||
fn unnominate(origin: T::Origin, target_index: u32) -> Result {
|
||||
fn unnominate(origin: T::Origin, target_index: Compact<u32>) -> Result {
|
||||
let source = ensure_signed(origin)?;
|
||||
let target_index: u32 = target_index.into();
|
||||
let target_index = target_index as usize;
|
||||
|
||||
let target = <Nominating<T>>::get(&source).ok_or("Account must be nominating")?;
|
||||
@@ -305,10 +310,11 @@ impl<T: Trait> Module<T> {
|
||||
/// An error (no-op) if `Self::intentions()[intentions_index] != origin`.
|
||||
fn register_preferences(
|
||||
origin: T::Origin,
|
||||
intentions_index: u32,
|
||||
intentions_index: Compact<u32>,
|
||||
prefs: ValidatorPrefs<T::Balance>
|
||||
) -> Result {
|
||||
let who = ensure_signed(origin)?;
|
||||
let intentions_index: u32 = intentions_index.into();
|
||||
|
||||
if Self::intentions().get(intentions_index as usize) != Some(&who) {
|
||||
return Err("Invalid index")
|
||||
@@ -322,20 +328,21 @@ impl<T: Trait> Module<T> {
|
||||
// PRIV DISPATCH
|
||||
|
||||
/// Set the number of sessions in an era.
|
||||
fn set_sessions_per_era(new: T::BlockNumber) -> Result {
|
||||
<NextSessionsPerEra<T>>::put(&new);
|
||||
fn set_sessions_per_era(new: <T::BlockNumber as HasCompact>::Type) -> Result {
|
||||
<NextSessionsPerEra<T>>::put(new.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The length of the bonding duration in eras.
|
||||
fn set_bonding_duration(new: T::BlockNumber) -> Result {
|
||||
<BondingDuration<T>>::put(&new);
|
||||
fn set_bonding_duration(new: <T::BlockNumber as HasCompact>::Type) -> Result {
|
||||
<BondingDuration<T>>::put(new.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The length of a staking era in sessions.
|
||||
fn set_validator_count(new: u32) -> Result {
|
||||
<ValidatorCount<T>>::put(&new);
|
||||
fn set_validator_count(new: Compact<u32>) -> Result {
|
||||
let new: u32 = new.into();
|
||||
<ValidatorCount<T>>::put(new);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -353,8 +360,9 @@ impl<T: Trait> Module<T> {
|
||||
|
||||
|
||||
/// Set the offline slash grace period.
|
||||
fn set_offline_slash_grace(new: u32) -> Result {
|
||||
<OfflineSlashGrace<T>>::put(&new);
|
||||
fn set_offline_slash_grace(new: Compact<u32>) -> Result {
|
||||
let new: u32 = new.into();
|
||||
<OfflineSlashGrace<T>>::put(new);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ fn note_offline_grace_should_work() {
|
||||
with_externalities(&mut new_test_ext(0, 3, 3, 0, true, 10), || {
|
||||
Balances::set_free_balance(&10, 70);
|
||||
Balances::set_free_balance(&20, 70);
|
||||
assert_ok!(Staking::set_offline_slash_grace(1));
|
||||
assert_ok!(Staking::set_offline_slash_grace(1.into()));
|
||||
assert_eq!(Staking::offline_slash_grace(), 1);
|
||||
|
||||
assert_eq!(Staking::slash_count(&10), 0);
|
||||
@@ -130,7 +130,7 @@ fn note_offline_auto_unstake_session_change_should_work() {
|
||||
with_externalities(&mut new_test_ext(0, 3, 3, 0, true, 10), || {
|
||||
Balances::set_free_balance(&10, 7000);
|
||||
Balances::set_free_balance(&20, 7000);
|
||||
assert_ok!(Staking::register_preferences(Origin::signed(10), 0, ValidatorPrefs { unstake_threshold: 1, validator_payment: 0 }));
|
||||
assert_ok!(Staking::register_preferences(Origin::signed(10), 0.into(), ValidatorPrefs { unstake_threshold: 1, validator_payment: 0 }));
|
||||
|
||||
assert_eq!(Staking::intentions(), vec![10, 20]);
|
||||
|
||||
@@ -236,7 +236,7 @@ fn staking_should_work() {
|
||||
assert_eq!(Staking::validator_count(), 2);
|
||||
assert_eq!(Session::validators(), vec![10, 20]);
|
||||
|
||||
assert_ok!(Staking::set_bonding_duration(2));
|
||||
assert_ok!(Staking::set_bonding_duration(2.into()));
|
||||
assert_eq!(Staking::bonding_duration(), 2);
|
||||
|
||||
// Block 1: Add three validators. No obvious change.
|
||||
@@ -257,7 +257,7 @@ fn staking_should_work() {
|
||||
// Block 3: Unstake highest, introduce another staker. No change yet.
|
||||
System::set_block_number(3);
|
||||
assert_ok!(Staking::stake(Origin::signed(3)));
|
||||
assert_ok!(Staking::unstake(Origin::signed(4), Staking::intentions().iter().position(|&x| x == 4).unwrap() as u32));
|
||||
assert_ok!(Staking::unstake(Origin::signed(4), (Staking::intentions().iter().position(|&x| x == 4).unwrap() as u32).into()));
|
||||
assert_eq!(Staking::current_era(), 1);
|
||||
Session::check_rotate_session(System::block_number());
|
||||
|
||||
@@ -269,7 +269,7 @@ fn staking_should_work() {
|
||||
|
||||
// Block 5: Transfer stake from highest to lowest. No change yet.
|
||||
System::set_block_number(5);
|
||||
assert_ok!(Balances::transfer(Origin::signed(4), 1.into(), 40));
|
||||
assert_ok!(Balances::transfer(Origin::signed(4), 1.into(), 40.into()));
|
||||
Session::check_rotate_session(System::block_number());
|
||||
|
||||
// Block 6: Lowest now validator.
|
||||
@@ -279,7 +279,7 @@ fn staking_should_work() {
|
||||
|
||||
// Block 7: Unstake three. No change yet.
|
||||
System::set_block_number(7);
|
||||
assert_ok!(Staking::unstake(Origin::signed(3), Staking::intentions().iter().position(|&x| x == 3).unwrap() as u32));
|
||||
assert_ok!(Staking::unstake(Origin::signed(3), (Staking::intentions().iter().position(|&x| x == 3).unwrap() as u32).into()));
|
||||
Session::check_rotate_session(System::block_number());
|
||||
assert_eq!(Session::validators(), vec![1, 3]);
|
||||
|
||||
@@ -312,7 +312,7 @@ fn nominating_and_rewards_should_work() {
|
||||
assert_eq!(Balances::total_balance(&4), 40);
|
||||
|
||||
System::set_block_number(2);
|
||||
assert_ok!(Staking::unnominate(Origin::signed(4), 0));
|
||||
assert_ok!(Staking::unnominate(Origin::signed(4), 0.into()));
|
||||
Session::check_rotate_session(System::block_number());
|
||||
assert_eq!(Staking::current_era(), 2);
|
||||
assert_eq!(Session::validators(), vec![3, 2]);
|
||||
@@ -323,7 +323,7 @@ fn nominating_and_rewards_should_work() {
|
||||
|
||||
System::set_block_number(3);
|
||||
assert_ok!(Staking::stake(Origin::signed(4)));
|
||||
assert_ok!(Staking::unstake(Origin::signed(3), Staking::intentions().iter().position(|&x| x == 3).unwrap() as u32));
|
||||
assert_ok!(Staking::unstake(Origin::signed(3), (Staking::intentions().iter().position(|&x| x == 3).unwrap() as u32).into()));
|
||||
assert_ok!(Staking::nominate(Origin::signed(3), 1.into()));
|
||||
Session::check_rotate_session(System::block_number());
|
||||
assert_eq!(Session::validators(), vec![1, 4]);
|
||||
@@ -355,7 +355,11 @@ fn rewards_with_off_the_table_should_work() {
|
||||
assert_eq!(Balances::total_balance(&3), 30);
|
||||
|
||||
System::set_block_number(2);
|
||||
assert_ok!(Staking::register_preferences(Origin::signed(1), Staking::intentions().into_iter().position(|i| i == 1).unwrap() as u32, ValidatorPrefs { unstake_threshold: 3, validator_payment: 4 }));
|
||||
assert_ok!(Staking::register_preferences(
|
||||
Origin::signed(1),
|
||||
(Staking::intentions().into_iter().position(|i| i == 1).unwrap() as u32).into(),
|
||||
ValidatorPrefs { unstake_threshold: 3, validator_payment: 4 }
|
||||
));
|
||||
Session::check_rotate_session(System::block_number());
|
||||
assert_eq!(Balances::total_balance(&1), 22);
|
||||
assert_eq!(Balances::total_balance(&2), 37);
|
||||
@@ -441,7 +445,7 @@ fn staking_eras_work() {
|
||||
|
||||
// Block 3: Schedule an era length change; no visible changes.
|
||||
System::set_block_number(3);
|
||||
assert_ok!(Staking::set_sessions_per_era(3));
|
||||
assert_ok!(Staking::set_sessions_per_era(3.into()));
|
||||
Session::check_rotate_session(System::block_number());
|
||||
assert_eq!(Session::current_index(), 3);
|
||||
assert_eq!(Staking::sessions_per_era(), 2);
|
||||
@@ -487,7 +491,7 @@ fn staking_balance_transfer_when_bonded_should_not_work() {
|
||||
with_externalities(&mut new_test_ext(0, 1, 3, 1, false, 0), || {
|
||||
Balances::set_free_balance(&1, 111);
|
||||
assert_ok!(Staking::stake(Origin::signed(1)));
|
||||
assert_noop!(Balances::transfer(Origin::signed(1), 2.into(), 69), "cannot transfer illiquid funds");
|
||||
assert_noop!(Balances::transfer(Origin::signed(1), 2.into(), 69.into()), "cannot transfer illiquid funds");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
hex-literal = { version = "0.1.0", optional = true }
|
||||
serde = { version = "1.0", default-features = false }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
substrate-metadata = { path = "../metadata", default-features = false }
|
||||
sr-std = { path = "../../core/sr-std", default-features = false }
|
||||
sr-io = { path = "../../core/sr-io", default-features = false }
|
||||
@@ -16,7 +16,7 @@ mashup = "0.1.7"
|
||||
|
||||
[dev-dependencies]
|
||||
pretty_assertions = "0.5.1"
|
||||
parity-codec-derive = { version = "2.0" }
|
||||
parity-codec-derive = { version = "2.1" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
|
||||
@@ -218,7 +218,7 @@ macro_rules! decl_module {
|
||||
match *self {
|
||||
$(
|
||||
$call_type::$fn_name( $( ref $param_name ),* ) =>
|
||||
$call_type::$fn_name( $( $param_name.clone() ),* )
|
||||
$call_type::$fn_name( $( (*$param_name).clone() ),* )
|
||||
,)*
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ hex-literal = "0.1.0"
|
||||
serde = { version = "1.0", default-features = false }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
safe-mix = { version = "1.0", default-features = false}
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec-derive = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
parity-codec-derive = { version = "2.1", default-features = false }
|
||||
substrate-primitives = { path = "../../core/primitives", default-features = false }
|
||||
sr-std = { path = "../../core/sr-std", default-features = false }
|
||||
sr-io = { path = "../../core/sr-io", default-features = false }
|
||||
|
||||
@@ -7,7 +7,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
hex-literal = "0.1.0"
|
||||
serde = { version = "1.0", default-features = false }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
substrate-primitives = { path = "../../core/primitives", default-features = false }
|
||||
sr-std = { path = "../../core/sr-std", default-features = false }
|
||||
sr-io = { path = "../../core/sr-io", default-features = false }
|
||||
|
||||
@@ -51,6 +51,7 @@ extern crate srml_system as system;
|
||||
extern crate srml_consensus as consensus;
|
||||
extern crate parity_codec as codec;
|
||||
|
||||
use codec::HasCompact;
|
||||
use runtime_support::{StorageValue, Parameter};
|
||||
use runtime_support::dispatch::Result;
|
||||
use runtime_primitives::traits::{As, OnFinalise, SimpleArithmetic, Zero};
|
||||
@@ -68,7 +69,7 @@ pub trait Trait: consensus::Trait + system::Trait {
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
fn set(origin, now: T::Moment) -> Result;
|
||||
fn set(origin, now: <T::Moment as HasCompact>::Type) -> Result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,8 +103,10 @@ impl<T: Trait> Module<T> {
|
||||
/// if this call hasn't been invoked by that time.
|
||||
///
|
||||
/// The timestamp should be greater than the previous one by the amount specified by `block_period`.
|
||||
fn set(origin: T::Origin, now: T::Moment) -> Result {
|
||||
fn set(origin: T::Origin, now: <T::Moment as HasCompact>::Type) -> Result {
|
||||
ensure_inherent(origin)?;
|
||||
let now = now.into();
|
||||
|
||||
assert!(!<Self as Store>::DidUpdate::exists(), "Timestamp must be updated only once in the block");
|
||||
assert!(
|
||||
<system::Module<T>>::extrinsic_index() == Some(T::TIMESTAMP_SET_POSITION),
|
||||
@@ -179,7 +182,7 @@ mod tests {
|
||||
|
||||
with_externalities(&mut TestExternalities::new(t), || {
|
||||
Timestamp::set_timestamp(42);
|
||||
assert_ok!(Timestamp::dispatch(Call::set(69), Origin::INHERENT));
|
||||
assert_ok!(Timestamp::dispatch(Call::set(69.into()), Origin::INHERENT));
|
||||
assert_eq!(Timestamp::now(), 69);
|
||||
});
|
||||
}
|
||||
@@ -192,8 +195,8 @@ mod tests {
|
||||
|
||||
with_externalities(&mut TestExternalities::new(t), || {
|
||||
Timestamp::set_timestamp(42);
|
||||
assert_ok!(Timestamp::dispatch(Call::set(69), Origin::INHERENT));
|
||||
let _ = Timestamp::dispatch(Call::set(70), Origin::INHERENT);
|
||||
assert_ok!(Timestamp::dispatch(Call::set(69.into()), Origin::INHERENT));
|
||||
let _ = Timestamp::dispatch(Call::set(70.into()), Origin::INHERENT);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -205,7 +208,7 @@ mod tests {
|
||||
|
||||
with_externalities(&mut TestExternalities::new(t), || {
|
||||
Timestamp::set_timestamp(42);
|
||||
let _ = Timestamp::dispatch(Call::set(46), Origin::INHERENT);
|
||||
let _ = Timestamp::dispatch(Call::set(46.into()), Origin::INHERENT);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
hex-literal = "0.1.0"
|
||||
serde = { version = "1.0", default-features = false }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
parity-codec = { version = "2.0", default-features = false }
|
||||
parity-codec-derive = { version = "2.0", default-features = false }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
parity-codec-derive = { version = "2.1", default-features = false }
|
||||
substrate-primitives = { path = "../../core/primitives", default-features = false }
|
||||
sr-std = { path = "../../core/sr-std", default-features = false }
|
||||
sr-io = { path = "../../core/sr-io", default-features = false }
|
||||
|
||||
@@ -29,6 +29,8 @@ extern crate sr_io as runtime_io;
|
||||
#[cfg(feature = "std")]
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
#[cfg(feature = "std")]
|
||||
extern crate serde;
|
||||
|
||||
#[macro_use]
|
||||
extern crate parity_codec_derive;
|
||||
@@ -44,7 +46,8 @@ use rstd::prelude::*;
|
||||
use runtime_support::{StorageValue, StorageMap};
|
||||
use runtime_support::dispatch::Result;
|
||||
use runtime_primitives::{Permill, traits::{OnFinalise, Zero, EnsureOrigin}};
|
||||
use balances::OnDilution;
|
||||
use codec::{HasCompact, Compact};
|
||||
use balances::{OnDilution, address::Address};
|
||||
use system::ensure_signed;
|
||||
|
||||
/// Our module's configuration trait. All our types and consts go in here. If the
|
||||
@@ -73,20 +76,20 @@ decl_module! {
|
||||
// Put forward a suggestion for spending. A deposit proportional to the value
|
||||
// is reserved and slashed if the proposal is rejected. It is returned once the
|
||||
// proposal is awarded.
|
||||
fn propose_spend(origin, value: T::Balance, beneficiary: T::AccountId) -> Result;
|
||||
fn propose_spend(origin, value: <T::Balance as HasCompact>::Type, beneficiary: Address<T::AccountId, T::AccountIndex>) -> Result;
|
||||
|
||||
// Set the balance of funds available to spend.
|
||||
fn set_pot(new_pot: T::Balance) -> Result;
|
||||
fn set_pot(new_pot: <T::Balance as HasCompact>::Type) -> Result;
|
||||
|
||||
// (Re-)configure this module.
|
||||
fn configure(proposal_bond: Permill, proposal_bond_minimum: T::Balance, spend_period: T::BlockNumber, burn: Permill) -> Result;
|
||||
fn configure(proposal_bond: Permill, proposal_bond_minimum: <T::Balance as HasCompact>::Type, spend_period: <T::BlockNumber as HasCompact>::Type, burn: Permill) -> Result;
|
||||
|
||||
// Reject a proposed spend. The original deposit will be slashed.
|
||||
fn reject_proposal(origin, roposal_id: ProposalIndex) -> Result;
|
||||
fn reject_proposal(origin, roposal_id: Compact<ProposalIndex>) -> Result;
|
||||
|
||||
// Approve a proposal. At a later time, the proposal will be allocated to the beneficiary
|
||||
// and the original deposit will be returned.
|
||||
fn approve_proposal(origin, proposal_id: ProposalIndex) -> Result;
|
||||
fn approve_proposal(origin, proposal_id: Compact<ProposalIndex>) -> Result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,8 +160,10 @@ impl<T: Trait> Module<T> {
|
||||
|
||||
// Implement Calls and add public immutables and private mutables.
|
||||
|
||||
fn propose_spend(origin: T::Origin, value: T::Balance, beneficiary: T::AccountId) -> Result {
|
||||
fn propose_spend(origin: T::Origin, value: <T::Balance as HasCompact>::Type, beneficiary: Address<T::AccountId, T::AccountIndex>) -> Result {
|
||||
let proposer = ensure_signed(origin)?;
|
||||
let beneficiary = <balances::Module<T>>::lookup(beneficiary)?;
|
||||
let value = value.into();
|
||||
|
||||
let bond = Self::calculate_bond(value);
|
||||
<balances::Module<T>>::reserve(&proposer, bond)
|
||||
@@ -173,8 +178,9 @@ impl<T: Trait> Module<T> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn reject_proposal(origin: T::Origin, proposal_id: ProposalIndex) -> Result {
|
||||
fn reject_proposal(origin: T::Origin, proposal_id: Compact<ProposalIndex>) -> Result {
|
||||
T::RejectOrigin::ensure_origin(origin)?;
|
||||
let proposal_id: ProposalIndex = proposal_id.into();
|
||||
|
||||
let proposal = <Proposals<T>>::take(proposal_id).ok_or("No proposal at that index")?;
|
||||
|
||||
@@ -184,8 +190,9 @@ impl<T: Trait> Module<T> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn approve_proposal(origin: T::Origin, proposal_id: ProposalIndex) -> Result {
|
||||
fn approve_proposal(origin: T::Origin, proposal_id: Compact<ProposalIndex>) -> Result {
|
||||
T::ApproveOrigin::ensure_origin(origin)?;
|
||||
let proposal_id = proposal_id.into();
|
||||
|
||||
ensure!(<Proposals<T>>::exists(proposal_id), "No proposal at that index");
|
||||
|
||||
@@ -194,9 +201,9 @@ impl<T: Trait> Module<T> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_pot(new_pot: T::Balance) -> Result {
|
||||
fn set_pot(new_pot: <T::Balance as HasCompact>::Type) -> Result {
|
||||
// Put the new value into storage.
|
||||
<Pot<T>>::put(new_pot);
|
||||
<Pot<T>>::put(new_pot.into());
|
||||
|
||||
// All good.
|
||||
Ok(())
|
||||
@@ -204,13 +211,13 @@ impl<T: Trait> Module<T> {
|
||||
|
||||
fn configure(
|
||||
proposal_bond: Permill,
|
||||
proposal_bond_minimum: T::Balance,
|
||||
spend_period: T::BlockNumber,
|
||||
proposal_bond_minimum: <T::Balance as HasCompact>::Type,
|
||||
spend_period: <T::BlockNumber as HasCompact>::Type,
|
||||
burn: Permill
|
||||
) -> Result {
|
||||
<ProposalBond<T>>::put(proposal_bond);
|
||||
<ProposalBondMinimum<T>>::put(proposal_bond_minimum);
|
||||
<SpendPeriod<T>>::put(spend_period);
|
||||
<ProposalBondMinimum<T>>::put(proposal_bond_minimum.into());
|
||||
<SpendPeriod<T>>::put(spend_period.into());
|
||||
<Burn<T>>::put(burn);
|
||||
Ok(())
|
||||
}
|
||||
@@ -373,7 +380,7 @@ mod tests {
|
||||
#[test]
|
||||
fn spend_proposal_takes_min_deposit() {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 1, 3));
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 1.into(), Address::Id(3)));
|
||||
assert_eq!(Balances::free_balance(&0), 99);
|
||||
assert_eq!(Balances::reserved_balance(&0), 1);
|
||||
});
|
||||
@@ -382,7 +389,7 @@ mod tests {
|
||||
#[test]
|
||||
fn spend_proposal_takes_proportional_deposit() {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3));
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100.into(), Address::Id(3)));
|
||||
assert_eq!(Balances::free_balance(&0), 95);
|
||||
assert_eq!(Balances::reserved_balance(&0), 5);
|
||||
});
|
||||
@@ -391,7 +398,7 @@ mod tests {
|
||||
#[test]
|
||||
fn spend_proposal_fails_when_proposer_poor() {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
assert_noop!(Treasury::propose_spend(Origin::signed(2), 100, 3), "Proposer's balance too low");
|
||||
assert_noop!(Treasury::propose_spend(Origin::signed(2), 100.into(), Address::Id(3)), "Proposer's balance too low");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -400,8 +407,8 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
Treasury::on_dilution(100, 100);
|
||||
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3));
|
||||
assert_ok!(Treasury::approve_proposal(Origin::ROOT, 0));
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100.into(), Address::Id(3)));
|
||||
assert_ok!(Treasury::approve_proposal(Origin::ROOT, 0.into()));
|
||||
|
||||
<Treasury as OnFinalise<u64>>::on_finalise(1);
|
||||
assert_eq!(Balances::free_balance(&3), 0);
|
||||
@@ -424,8 +431,8 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
Treasury::on_dilution(100, 100);
|
||||
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3));
|
||||
assert_ok!(Treasury::reject_proposal(Origin::ROOT, 0));
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100.into(), Address::Id(3)));
|
||||
assert_ok!(Treasury::reject_proposal(Origin::ROOT, 0.into()));
|
||||
|
||||
<Treasury as OnFinalise<u64>>::on_finalise(2);
|
||||
assert_eq!(Balances::free_balance(&3), 0);
|
||||
@@ -438,23 +445,23 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
Treasury::on_dilution(100, 100);
|
||||
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3));
|
||||
assert_ok!(Treasury::reject_proposal(Origin::ROOT, 0));
|
||||
assert_noop!(Treasury::reject_proposal(Origin::ROOT, 0), "No proposal at that index");
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100.into(), Address::Id(3)));
|
||||
assert_ok!(Treasury::reject_proposal(Origin::ROOT, 0.into()));
|
||||
assert_noop!(Treasury::reject_proposal(Origin::ROOT, 0.into()), "No proposal at that index");
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reject_non_existant_spend_proposal_fails() {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
assert_noop!(Treasury::reject_proposal(Origin::ROOT, 0), "No proposal at that index");
|
||||
assert_noop!(Treasury::reject_proposal(Origin::ROOT, 0.into()), "No proposal at that index");
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn accept_non_existant_spend_proposal_fails() {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
assert_noop!(Treasury::approve_proposal(Origin::ROOT, 0), "No proposal at that index");
|
||||
assert_noop!(Treasury::approve_proposal(Origin::ROOT, 0.into()), "No proposal at that index");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -463,9 +470,9 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
Treasury::on_dilution(100, 100);
|
||||
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3));
|
||||
assert_ok!(Treasury::reject_proposal(Origin::ROOT, 0));
|
||||
assert_noop!(Treasury::approve_proposal(Origin::ROOT, 0), "No proposal at that index");
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100.into(), Address::Id(3)));
|
||||
assert_ok!(Treasury::reject_proposal(Origin::ROOT, 0.into()));
|
||||
assert_noop!(Treasury::approve_proposal(Origin::ROOT, 0.into()), "No proposal at that index");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -474,8 +481,8 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
Treasury::on_dilution(100, 100);
|
||||
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3));
|
||||
assert_ok!(Treasury::approve_proposal(Origin::ROOT, 0));
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100.into(), Address::Id(3)));
|
||||
assert_ok!(Treasury::approve_proposal(Origin::ROOT, 0.into()));
|
||||
|
||||
<Treasury as OnFinalise<u64>>::on_finalise(2);
|
||||
assert_eq!(Balances::free_balance(&3), 100);
|
||||
@@ -488,8 +495,8 @@ mod tests {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
Treasury::on_dilution(100, 100);
|
||||
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 150, 3));
|
||||
assert_ok!(Treasury::approve_proposal(Origin::ROOT, 0));
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 150.into(), Address::Id(3)));
|
||||
assert_ok!(Treasury::approve_proposal(Origin::ROOT, 0.into()));
|
||||
|
||||
<Treasury as OnFinalise<u64>>::on_finalise(2);
|
||||
assert_eq!(Treasury::pot(), 100);
|
||||
|
||||
Reference in New Issue
Block a user