bugfix: balances::transfer for new_account issue#722 (#731)

* bugfix: balances::transfer for new_account

issue:#722
would_create flag should depend on dest, not origin.
change 
```rust
let would_create = from_balance.is_zero();
```
to 
```rust
    let to_balance = Self::free_balance(&dest); 
    let would_create = to_balance.is_zero(); 
```
in the other hand, provide `fn new_test_ext2()` and let `transfer_fee=10`, `creation_fee=50` for test case

* Update lib.rs

* Update tests.rs

* Make `impl_outer_origin!` support generic `Origin`s (#732)

* Make `impl_outer_origin!` support generic `Origin`s

* Support empty outer origin

* Contracts: fix transfer function. (#733)

* Remove dependency on the parity repo (#734)

* Fix test

* Anothe fix
This commit is contained in:
金XX(Aton)
2018-09-13 21:54:56 +08:00
committed by Gav Wood
parent a7f8f0f1bd
commit ca8f0d6625
4 changed files with 112 additions and 3 deletions
+2 -2
View File
@@ -284,7 +284,8 @@ impl<T: Trait> Module<T> {
let dest = Self::lookup(dest)?;
let from_balance = Self::free_balance(&transactor);
let would_create = from_balance.is_zero();
let to_balance = Self::free_balance(&dest);
let would_create = to_balance.is_zero();
let fee = if would_create { Self::creation_fee() } else { Self::transfer_fee() };
let liability = value + fee;
@@ -297,7 +298,6 @@ impl<T: Trait> Module<T> {
}
T::EnsureAccountLiquid::ensure_account_liquid(&transactor)?;
let to_balance = Self::free_balance(&dest);
// NOTE: total stake being stored in the same type means that this could never overflow
// but better to be safe than sorry.
let new_to_balance = match to_balance.checked_add(&value) {