diff --git a/Cargo.lock b/Cargo.lock index 473798f103ac9..d90ee464e61b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3107,6 +3107,7 @@ dependencies = [ "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", + "srml-fees 0.1.0", "srml-support 0.1.0", "srml-system 0.1.0", "substrate-keyring 0.1.0", @@ -3169,6 +3170,7 @@ dependencies = [ "sr-std 0.1.0", "srml-balances 0.1.0", "srml-democracy 0.1.0", + "srml-fees 0.1.0", "srml-support 0.1.0", "srml-system 0.1.0", "substrate-primitives 0.1.0", @@ -3187,6 +3189,7 @@ dependencies = [ "sr-primitives 0.1.0", "sr-std 0.1.0", "srml-balances 0.1.0", + "srml-fees 0.1.0", "srml-support 0.1.0", "srml-system 0.1.0", "substrate-primitives 0.1.0", @@ -3202,6 +3205,7 @@ dependencies = [ "sr-io 0.1.0", "sr-primitives 0.1.0", "srml-balances 0.1.0", + "srml-fees 0.1.0", "srml-support 0.1.0", "srml-system 0.1.0", "substrate-primitives 0.1.0", @@ -3341,6 +3345,7 @@ dependencies = [ "sr-std 0.1.0", "srml-balances 0.1.0", "srml-consensus 0.1.0", + "srml-fees 0.1.0", "srml-session 0.1.0", "srml-support 0.1.0", "srml-system 0.1.0", @@ -3461,6 +3466,7 @@ dependencies = [ "sr-primitives 0.1.0", "sr-std 0.1.0", "srml-balances 0.1.0", + "srml-fees 0.1.0", "srml-support 0.1.0", "srml-system 0.1.0", "substrate-primitives 0.1.0", diff --git a/core/test-runtime/wasm/Cargo.lock b/core/test-runtime/wasm/Cargo.lock index fdba699543195..26e287283b188 100644 --- a/core/test-runtime/wasm/Cargo.lock +++ b/core/test-runtime/wasm/Cargo.lock @@ -1159,7 +1159,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "schnorrkel" version = "0.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/w3f/schnorrkel#3179838da9dd4896c12bb910e7c42477a3250641" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1168,6 +1168,7 @@ dependencies = [ "merlin 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1441,11 +1442,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "substrate-bip39" version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/paritytech/substrate-bip39#a28806512c977992af8d6740d45352f5a1c832a0" dependencies = [ "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1568,12 +1569,12 @@ dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", - "substrate-bip39 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "substrate-bip39 0.2.0 (git+https://github.com/paritytech/substrate-bip39)", "tiny-bip39 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "twox-hash 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2206,7 +2207,7 @@ dependencies = [ "checksum rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" -"checksum schnorrkel 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe554f318830b48e5da8ab1ccb1ffd02b79228364dac7766b7cd1ec461ca5116" +"checksum schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)" = "" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" @@ -2226,7 +2227,7 @@ dependencies = [ "checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" -"checksum substrate-bip39 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ec6183ce9e04bec5f113ff19c8ef5355dad20a4196134b5402732bf5d3c1a351" +"checksum substrate-bip39 0.2.0 (git+https://github.com/paritytech/substrate-bip39)" = "" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" "checksum subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "702662512f3ddeb74a64ce2fbbf3707ee1b6bb663d28bb054e0779bbc720d926" "checksum syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)" = "525bd55255f03c816e5d7f615587bd13030c7103354fadb104993dcee6a788ec" diff --git a/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm b/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm index 416fd30a5c971..ad8450841e0fd 100644 Binary files a/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm and b/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm differ diff --git a/node-template/runtime/src/lib.rs b/node-template/runtime/src/lib.rs index fd696e9500a85..ccd647b7ae82e 100644 --- a/node-template/runtime/src/lib.rs +++ b/node-template/runtime/src/lib.rs @@ -158,6 +158,8 @@ impl balances::Trait for Runtime { type OnFreeBalanceZero = (); /// What to do if a new account is created. type OnNewAccount = Indices; + /// Charge fee. + type ChargeFee = Fees; /// The uniquitous event type. type Event = Event; } diff --git a/node-template/runtime/wasm/Cargo.lock b/node-template/runtime/wasm/Cargo.lock index 622198affb571..ca662281131ce 100644 --- a/node-template/runtime/wasm/Cargo.lock +++ b/node-template/runtime/wasm/Cargo.lock @@ -1201,7 +1201,7 @@ dependencies = [ [[package]] name = "schnorrkel" version = "0.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/w3f/schnorrkel#3179838da9dd4896c12bb910e7c42477a3250641" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1210,6 +1210,7 @@ dependencies = [ "merlin 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1437,6 +1438,7 @@ dependencies = [ "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "sr-std 0.1.0", + "srml-fees 0.1.0", "srml-support 0.1.0", "srml-system 0.1.0", "substrate-keyring 0.1.0", @@ -1659,11 +1661,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "substrate-bip39" version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/paritytech/substrate-bip39#a28806512c977992af8d6740d45352f5a1c832a0" dependencies = [ "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1786,12 +1788,12 @@ dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", - "substrate-bip39 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "substrate-bip39 0.2.0 (git+https://github.com/paritytech/substrate-bip39)", "tiny-bip39 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "twox-hash 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2396,7 +2398,7 @@ dependencies = [ "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" "checksum safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7bf422d23a88c16d5090d455f182bc99c60af4df6a345c63428acf5129e347" -"checksum schnorrkel 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe554f318830b48e5da8ab1ccb1ffd02b79228364dac7766b7cd1ec461ca5116" +"checksum schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)" = "" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" @@ -2416,7 +2418,7 @@ dependencies = [ "checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" -"checksum substrate-bip39 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ec6183ce9e04bec5f113ff19c8ef5355dad20a4196134b5402732bf5d3c1a351" +"checksum substrate-bip39 0.2.0 (git+https://github.com/paritytech/substrate-bip39)" = "" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" "checksum subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "702662512f3ddeb74a64ce2fbbf3707ee1b6bb663d28bb054e0779bbc720d926" "checksum syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)" = "525bd55255f03c816e5d7f615587bd13030c7103354fadb104993dcee6a788ec" diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 45b252b04cb67..212f91083ae67 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -60,7 +60,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("node"), impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, - spec_version: 34, + spec_version: 35, impl_version: 35, apis: RUNTIME_API_VERSIONS, }; @@ -103,6 +103,7 @@ impl balances::Trait for Runtime { type Balance = Balance; type OnFreeBalanceZero = ((Staking, Contract), Session); type OnNewAccount = Indices; + type ChargeFee = fees::Module; type Event = Event; } @@ -178,6 +179,7 @@ impl contract::Trait for Runtime { type Gas = u64; type DetermineContractAddress = contract::SimpleAddressDeterminator; type ComputeDispatchFee = contract::DefaultDispatchFeeComputor; + type ChargeFee = fees::Module; } impl sudo::Trait for Runtime { diff --git a/node/runtime/wasm/Cargo.lock b/node/runtime/wasm/Cargo.lock index f6cfef7c80957..438d508b4361c 100644 --- a/node/runtime/wasm/Cargo.lock +++ b/node/runtime/wasm/Cargo.lock @@ -1236,7 +1236,7 @@ dependencies = [ [[package]] name = "schnorrkel" version = "0.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/w3f/schnorrkel#3179838da9dd4896c12bb910e7c42477a3250641" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1245,6 +1245,7 @@ dependencies = [ "merlin 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1482,6 +1483,7 @@ dependencies = [ "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "sr-std 0.1.0", + "srml-fees 0.1.0", "srml-support 0.1.0", "srml-system 0.1.0", "substrate-keyring 0.1.0", @@ -1818,11 +1820,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "substrate-bip39" version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/paritytech/substrate-bip39#a28806512c977992af8d6740d45352f5a1c832a0" dependencies = [ "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1956,12 +1958,12 @@ dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", - "substrate-bip39 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "substrate-bip39 0.2.0 (git+https://github.com/paritytech/substrate-bip39)", "tiny-bip39 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "twox-hash 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2567,7 +2569,7 @@ dependencies = [ "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" "checksum safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7bf422d23a88c16d5090d455f182bc99c60af4df6a345c63428acf5129e347" -"checksum schnorrkel 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe554f318830b48e5da8ab1ccb1ffd02b79228364dac7766b7cd1ec461ca5116" +"checksum schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)" = "" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" @@ -2587,7 +2589,7 @@ dependencies = [ "checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" -"checksum substrate-bip39 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ec6183ce9e04bec5f113ff19c8ef5355dad20a4196134b5402732bf5d3c1a351" +"checksum substrate-bip39 0.2.0 (git+https://github.com/paritytech/substrate-bip39)" = "" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" "checksum subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "702662512f3ddeb74a64ce2fbbf3707ee1b6bb663d28bb054e0779bbc720d926" "checksum syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)" = "525bd55255f03c816e5d7f615587bd13030c7103354fadb104993dcee6a788ec" diff --git a/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm b/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm index 2192c80bc519e..20242fc59077e 100644 Binary files a/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm and b/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm differ diff --git a/srml/balances/Cargo.toml b/srml/balances/Cargo.toml index c8d5d152a3e76..b1a18e200fd5c 100644 --- a/srml/balances/Cargo.toml +++ b/srml/balances/Cargo.toml @@ -14,6 +14,7 @@ rstd = { package = "sr-std", path = "../../core/sr-std", default-features = fals primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false } srml-support = { path = "../support", default-features = false } system = { package = "srml-system", path = "../system", default-features = false } +fees = { package = "srml-fees", path = "../fees", default-features = false } [dev-dependencies] runtime_io = { package = "sr-io", path = "../../core/sr-io" } diff --git a/srml/balances/src/lib.rs b/srml/balances/src/lib.rs index c9b62998fc070..d1b15dfd465aa 100644 --- a/srml/balances/src/lib.rs +++ b/srml/balances/src/lib.rs @@ -29,12 +29,12 @@ use rstd::{cmp, result}; use parity_codec::{Codec, Encode, Decode}; use srml_support::{StorageValue, StorageMap, Parameter, decl_event, decl_storage, decl_module, ensure}; use srml_support::traits::{ - UpdateBalanceOutcome, Currency, OnFreeBalanceZero, TransferAsset, + UpdateBalanceOutcome, Currency, OnFreeBalanceZero, TransferAsset, ChargeFee, WithdrawReason, WithdrawReasons, ArithmeticType, LockIdentifier, LockableCurrency }; use srml_support::dispatch::Result; use primitives::traits::{ - Zero, SimpleArithmetic, As, StaticLookup, Member, CheckedAdd, CheckedSub, MaybeSerializeDebug + Zero, SimpleArithmetic, As, StaticLookup, Member, CheckedAdd, CheckedSub, MaybeSerializeDebug, }; use system::{IsDeadAccount, OnNewAccount, ensure_signed}; @@ -54,6 +54,9 @@ pub trait Trait: system::Trait { /// Handler for when a new account is created. type OnNewAccount: OnNewAccount; + /// Charge fee. + type ChargeFee: ChargeFee; + /// The overarching event type. type Event: From> + Into<::Event>; } @@ -189,7 +192,7 @@ decl_module! { ) { let transactor = ensure_signed(origin)?; let dest = T::Lookup::lookup(dest)?; - Self::make_transfer(&transactor, &dest, value)?; + Self::make_transfer(&transactor, &dest, value, true)?; } /// Set the balances of a given account. @@ -284,8 +287,14 @@ impl Module { } } - /// Transfer some liquid free balance to another staker. - pub fn make_transfer(transactor: &T::AccountId, dest: &T::AccountId, value: T::Balance) -> Result { + /// Transfer some liquid free balance to another account. If `can_kill`, will enforce + /// ExistentialDeposit law anulling the `transactor`'s account as needed. + pub fn make_transfer( + transactor: &T::AccountId, + dest: &T::AccountId, + value: T::Balance, + can_kill: bool, + ) -> Result { let from_balance = Self::free_balance(transactor); let to_balance = Self::free_balance(dest); let would_create = to_balance.is_zero(); @@ -311,9 +320,14 @@ impl Module { None => return Err("destination balance too high to receive value"), }; + if !can_kill { + ensure!(new_from_balance >= Self::existential_deposit(), "balance too low to send value") + } + if transactor != dest { + T::ChargeFee::charge_fee(transactor, fee)?; + Self::set_free_balance(transactor, new_from_balance); - Self::decrease_total_stake_by(fee); Self::set_free_balance_creating(dest, new_to_balance); Self::deposit_event(RawEvent::Transfer(transactor.clone(), dest.clone(), value, fee)); } @@ -595,12 +609,13 @@ impl TransferAsset for Module { type Amount = T::Balance; fn transfer(from: &T::AccountId, to: &T::AccountId, amount: T::Balance) -> Result { - Self::make_transfer(from, to, amount) + Self::make_transfer(from, to, amount, false) } fn withdraw(who: &T::AccountId, value: T::Balance, reason: WithdrawReason) -> Result { let b = Self::free_balance(who); - ensure!(b >= value, "account has too few funds"); + // ensure `who`'s account won't be killed. + ensure!(b >= value + Self::existential_deposit(), "account has too few funds"); let new_balance = b - value; Self::ensure_account_can_withdraw(who, value, reason, new_balance)?; Self::set_free_balance(who, new_balance); diff --git a/srml/balances/src/mock.rs b/srml/balances/src/mock.rs index 55403a12aa4d1..fc93b0f058ef1 100644 --- a/srml/balances/src/mock.rs +++ b/srml/balances/src/mock.rs @@ -23,6 +23,7 @@ use primitives::{traits::{IdentityLookup}, testing::{Digest, DigestItem, Header} use substrate_primitives::{H256, Blake2Hasher}; use runtime_io; use srml_support::impl_outer_origin; +use fees; use crate::{GenesisConfig, Module, Trait}; impl_outer_origin!{ @@ -45,10 +46,15 @@ impl system::Trait for Runtime { type Event = (); type Log = DigestItem; } +impl fees::Trait for Runtime { + type Event = (); + type TransferAsset = Balances; +} impl Trait for Runtime { type Balance = u64; type OnFreeBalanceZero = (); type OnNewAccount = (); + type ChargeFee = fees::Module; type Event = (); } diff --git a/srml/balances/src/tests.rs b/srml/balances/src/tests.rs index 7fded7068a471..6230eac554580 100644 --- a/srml/balances/src/tests.rs +++ b/srml/balances/src/tests.rs @@ -110,7 +110,7 @@ fn lock_reasons_should_work() { assert_ok!(>::withdraw(&1, 1, WithdrawReason::TransactionPayment)); Balances::set_lock(ID_1, &1, 10, u64::max_value(), WithdrawReason::TransactionPayment.into()); - assert_ok!(>::transfer(&1, &2, 1)); + assert_ok!(Balances::ensure_account_can_withdraw(&1, 1, WithdrawReason::Transfer, 9)); assert_ok!(>::reserve(&1, 1)); assert_noop!(>::withdraw(&1, 1, WithdrawReason::TransactionPayment), "account liquidity restrictions prevent withdrawal"); }); @@ -283,6 +283,31 @@ fn balance_transfer_works() { }); } +#[test] +fn balance_transfer_with_creation_fee_works() { + with_externalities(&mut ExtBuilder::default().creation_fee(3).build(), || { + Balances::set_free_balance(&1, 111); + Balances::increase_total_stake_by(111); + assert_ok!(Balances::transfer(Some(1).into(), 2, 69)); + // new_from_balance = balance - transfer_amount - creation_fee + assert_eq!(Balances::total_balance(&1), 111 - 69 - 3); + assert_eq!(Balances::total_balance(&2), 69); + }); +} + +#[test] +fn balance_transfer_with_transfer_fee_works() { + with_externalities(&mut ExtBuilder::default().transfer_fee(3).build(), || { + Balances::set_free_balance(&1, 111); + Balances::increase_total_stake_by(111); + Balances::set_free_balance(&2, 7); + assert_ok!(Balances::transfer(Some(1).into(), 2, 69)); + // new_from_balance = balance - transfer_amount - transfer_fee + assert_eq!(Balances::total_balance(&1), 111 - 69 - 3); + assert_eq!(Balances::total_balance(&2), 7 + 69); + }); +} + #[test] fn reserving_balance_should_work() { with_externalities(&mut ExtBuilder::default().build(), || { diff --git a/srml/contract/src/gas.rs b/srml/contract/src/gas.rs index fb96ff66e5240..009a2c7064098 100644 --- a/srml/contract/src/gas.rs +++ b/srml/contract/src/gas.rs @@ -15,10 +15,9 @@ // along with Substrate. If not, see . use crate::{GasSpent, Module, Trait}; -use balances; use runtime_primitives::BLOCK_FULL; use runtime_primitives::traits::{As, CheckedMul, CheckedSub, Zero}; -use srml_support::StorageValue; +use srml_support::{StorageValue, traits::ChargeFee}; #[cfg(test)] use std::{any::Any, fmt::Debug}; @@ -213,18 +212,12 @@ pub fn buy_gas( // Buy the specified amount of gas. let gas_price = >::gas_price(); - let b = >::free_balance(transactor); let cost = >::as_(gas_limit.clone()) .checked_mul(&gas_price) .ok_or("overflow multiplying gas limit by price")?; - let new_balance = b.checked_sub(&cost); - if new_balance < Some(>::existential_deposit()) { - return Err("not enough funds for transaction fee"); - } + ::ChargeFee::charge_fee(transactor, cost)?; - >::set_free_balance(transactor, b - cost); - >::decrease_total_stake_by(cost); Ok(GasMeter { limit: gas_limit, gas_left: gas_limit, @@ -243,10 +236,9 @@ pub fn refund_unused_gas(transactor: &T::AccountId, gas_meter: GasMete >::put(gas_spent); // Refund gas left by the price it was bought. - let b = >::free_balance(transactor); let refund = >::as_(gas_meter.gas_left) * gas_meter.gas_price; - >::set_free_balance(transactor, b + refund); - >::increase_total_stake_by(refund); + // This cannot fail, since `refund` is never greater than bought amount. + let _ = ::ChargeFee::refund_fee(transactor, refund); } /// A little handy utility for converting a value in balance units into approximitate value in gas units diff --git a/srml/contract/src/lib.rs b/srml/contract/src/lib.rs index 8de372ffe894d..758f921aceb63 100644 --- a/srml/contract/src/lib.rs +++ b/srml/contract/src/lib.rs @@ -70,10 +70,10 @@ use serde_derive::{Serialize, Deserialize}; use rstd::prelude::*; use rstd::marker::PhantomData; use parity_codec::{Codec, Encode, Decode}; -use runtime_primitives::traits::{Hash, As, SimpleArithmetic,Bounded, StaticLookup}; +use runtime_primitives::traits::{Hash, As, SimpleArithmetic,Bounded, StaticLookup }; use srml_support::dispatch::{Result, Dispatchable}; use srml_support::{Parameter, StorageMap, StorageValue, StorageDoubleMap, decl_module, decl_event, decl_storage}; -use srml_support::traits::OnFreeBalanceZero; +use srml_support::traits::{OnFreeBalanceZero, ChargeFee}; use system::{ensure_signed, RawOrigin}; use runtime_io::{blake2_256, twox_128}; use timestamp; @@ -104,6 +104,9 @@ pub trait Trait: fees::Trait + balances::Trait + timestamp::Trait { /// A function type to get the contract address given the creator. type DetermineContractAddress: ContractAddressFor, Self::AccountId>; + /// Fee charge. + type ChargeFee: ChargeFee; + /// A function type that computes the fee for dispatching the given `Call`. /// /// It is recommended (though not required) for this function to return a fee that would be taken diff --git a/srml/contract/src/tests.rs b/srml/contract/src/tests.rs index cf280c0f007c9..60066ae4e3b63 100644 --- a/srml/contract/src/tests.rs +++ b/srml/contract/src/tests.rs @@ -77,6 +77,7 @@ impl balances::Trait for Test { type Balance = u64; type OnFreeBalanceZero = Contract; type OnNewAccount = (); + type ChargeFee = Fees; type Event = MetaEvent; } impl timestamp::Trait for Test { @@ -98,11 +99,13 @@ impl Trait for Test { type DetermineContractAddress = DummyContractAddressFor; type Event = MetaEvent; type ComputeDispatchFee = DummyComputeDispatchFee; + type ChargeFee = Fees; } type Balances = balances::Module; type Contract = Module; type System = system::Module; +type Fees = fees::Module; pub struct DummyContractAddressFor; impl ContractAddressFor for DummyContractAddressFor { diff --git a/srml/council/Cargo.toml b/srml/council/Cargo.toml index 868ec3bcff038..a337f9c4102f0 100644 --- a/srml/council/Cargo.toml +++ b/srml/council/Cargo.toml @@ -20,6 +20,7 @@ system = { package = "srml-system", path = "../system", default-features = false [dev-dependencies] hex-literal = "0.1.0" balances = { package = "srml-balances", path = "../balances" } +fees = { package = "srml-fees", path = "../fees" } [features] default = ["std"] diff --git a/srml/council/src/lib.rs b/srml/council/src/lib.rs index de64b8c55c507..6e2c344edebe4 100644 --- a/srml/council/src/lib.rs +++ b/srml/council/src/lib.rs @@ -45,7 +45,7 @@ mod tests { impl_outer_event! { pub enum Event for Test { - balances, democracy, seats, voting, motions, + balances, fees, democracy, seats, voting, motions, } } @@ -76,8 +76,13 @@ mod tests { type Balance = u64; type OnFreeBalanceZero = (); type OnNewAccount = (); + type ChargeFee = fees::Module; type Event = Event; } + impl fees::Trait for Test { + type Event = Event; + type TransferAsset = balances::Module; + } impl democracy::Trait for Test { type Currency = balances::Module; type Proposal = Call; diff --git a/srml/democracy/Cargo.toml b/srml/democracy/Cargo.toml index 29b70938f20c1..d2d3a97a467ce 100644 --- a/srml/democracy/Cargo.toml +++ b/srml/democracy/Cargo.toml @@ -19,6 +19,7 @@ system = { package = "srml-system", path = "../system", default-features = false [dev-dependencies] substrate-primitives = { path = "../../core/primitives" } balances = { package = "srml-balances", path = "../balances" } +fees = { package = "srml-fees", path = "../fees" } [features] default = ["std"] diff --git a/srml/democracy/src/lib.rs b/srml/democracy/src/lib.rs index fb2ee276681d5..b170fe5241a67 100644 --- a/srml/democracy/src/lib.rs +++ b/srml/democracy/src/lib.rs @@ -453,8 +453,13 @@ mod tests { type Balance = u64; type OnFreeBalanceZero = (); type OnNewAccount = (); + type ChargeFee = fees::Module; type Event = (); } + impl fees::Trait for Test { + type Event = (); + type TransferAsset = balances::Module; + } impl Trait for Test { type Currency = balances::Module; type Proposal = Call; diff --git a/srml/example/Cargo.toml b/srml/example/Cargo.toml index c1cf286346402..6cc3cb8a85113 100644 --- a/srml/example/Cargo.toml +++ b/srml/example/Cargo.toml @@ -16,6 +16,7 @@ balances = { package = "srml-balances", path = "../balances", default-features = sr-io = { path = "../../core/sr-io" } substrate-primitives = { path = "../../core/primitives" } sr-primitives = { path = "../../core/sr-primitives" } +fees = { package = "srml-fees", path = "../fees" } [features] default = ["std"] diff --git a/srml/example/src/lib.rs b/srml/example/src/lib.rs index e6f3cf9264d4b..9a4b61009d145 100644 --- a/srml/example/src/lib.rs +++ b/srml/example/src/lib.rs @@ -280,8 +280,13 @@ mod tests { type Balance = u64; type OnFreeBalanceZero = (); type OnNewAccount = (); + type ChargeFee = fees::Module; type Event = (); } + impl fees::Trait for Test { + type Event = (); + type TransferAsset = balances::Module; + } impl Trait for Test { type Event = (); } diff --git a/srml/executive/src/lib.rs b/srml/executive/src/lib.rs index d00c2693ffafb..be42753806587 100644 --- a/srml/executive/src/lib.rs +++ b/srml/executive/src/lib.rs @@ -319,6 +319,7 @@ mod tests { type Balance = u64; type OnFreeBalanceZero = (); type OnNewAccount = (); + type ChargeFee = fees::Module; type Event = MetaEvent; } impl fees::Trait for Runtime { diff --git a/srml/staking/Cargo.toml b/srml/staking/Cargo.toml index c548b3a2ef117..eb46106e9944c 100644 --- a/srml/staking/Cargo.toml +++ b/srml/staking/Cargo.toml @@ -22,6 +22,7 @@ session = { package = "srml-session", path = "../session", default-features = fa substrate-primitives = { path = "../../core/primitives" } timestamp = { package = "srml-timestamp", path = "../timestamp" } balances = { package = "srml-balances", path = "../balances" } +fees = { package = "srml-fees", path = "../fees" } [features] default = ["std"] diff --git a/srml/staking/src/mock.rs b/srml/staking/src/mock.rs index 529c8b625f41c..80171ba00815b 100644 --- a/srml/staking/src/mock.rs +++ b/srml/staking/src/mock.rs @@ -54,8 +54,13 @@ impl balances::Trait for Test { type Balance = u64; type OnFreeBalanceZero = Staking; type OnNewAccount = (); + type ChargeFee = fees::Module; type Event = (); } +impl fees::Trait for Test { + type Event = (); + type TransferAsset = balances::Module; +} impl session::Trait for Test { type ConvertAccountIdToSessionKey = ConvertUintAuthorityId; type OnSessionChange = Staking; diff --git a/srml/treasury/Cargo.toml b/srml/treasury/Cargo.toml index 9bfb4b1725e71..cc33c8ef9e2d5 100644 --- a/srml/treasury/Cargo.toml +++ b/srml/treasury/Cargo.toml @@ -18,6 +18,7 @@ balances = { package = "srml-balances", path = "../balances", default-features = [dev-dependencies] runtime_io = { package = "sr-io", path = "../../core/sr-io" } substrate-primitives = { path = "../../core/primitives" } +fees = { package = "srml-fees", path = "../fees" } [features] default = ["std"] diff --git a/srml/treasury/src/lib.rs b/srml/treasury/src/lib.rs index aa0eec6479ec5..c17d0f0ebe8e8 100644 --- a/srml/treasury/src/lib.rs +++ b/srml/treasury/src/lib.rs @@ -287,8 +287,13 @@ mod tests { type Balance = u64; type OnNewAccount = (); type OnFreeBalanceZero = (); + type ChargeFee = fees::Module; type Event = (); } + impl fees::Trait for Test { + type Event = (); + type TransferAsset = balances::Module; + } impl Trait for Test { type Currency = balances::Module; type ApproveOrigin = system::EnsureRoot;