mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 02:11:07 +00:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user