-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Remove deprecated pallet_balances's set_balance_deprecated and transfer dispatchables
#1226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
be30e7e
f085aab
33ea65a
4065d12
141d165
e09564f
d362ce3
bf11c73
57f22e0
b46095c
3a8fae6
498d086
72b3a0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| title: Removed deprecated `Balances::transfer` and `Balances::set_balance_deprecated` functions. | ||
|
|
||
| doc: | ||
| - audience: Builder | ||
| description: The Balances pallet's dispatchables `set_balance_deprecated` and `transfer` were deprecated in [paritytech/substrate#12951](https://github.com/paritytech/substrate/pull/12951) and have now been removed. | ||
| notes: | ||
| - Use `set_balance_deprecated` instead `force_set_balance` and `transfer_allow_death` instead of `transfer`. | ||
|
|
||
| migrations: | ||
| db: [] | ||
|
|
||
| runtime: [] | ||
|
|
||
| crates: | ||
| - name: pallet-balances | ||
|
|
||
| host_functions: [] | ||
KiChjang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -563,53 +563,6 @@ pub mod pallet { | |
| Ok(()) | ||
| } | ||
|
|
||
| /// Set the regular balance of a given account; it also takes a reserved balance but this | ||
| /// must be the same as the account's current reserved balance. | ||
| /// | ||
| /// The dispatch origin for this call is `root`. | ||
| /// | ||
| /// WARNING: This call is DEPRECATED! Use `force_set_balance` instead. | ||
| #[pallet::call_index(1)] | ||
| #[pallet::weight( | ||
| T::WeightInfo::force_set_balance_creating() // Creates a new account. | ||
| .max(T::WeightInfo::force_set_balance_killing()) // Kills an existing account. | ||
| )] | ||
| pub fn set_balance_deprecated( | ||
| origin: OriginFor<T>, | ||
| who: AccountIdLookupOf<T>, | ||
| #[pallet::compact] new_free: T::Balance, | ||
| #[pallet::compact] old_reserved: T::Balance, | ||
| ) -> DispatchResult { | ||
| ensure_root(origin)?; | ||
| let who = T::Lookup::lookup(who)?; | ||
| let existential_deposit = Self::ed(); | ||
|
|
||
| let wipeout = new_free < existential_deposit; | ||
| let new_free = if wipeout { Zero::zero() } else { new_free }; | ||
|
|
||
| // First we try to modify the account's balance to the forced balance. | ||
| let old_free = Self::try_mutate_account_handling_dust( | ||
| &who, | ||
| |account, _is_new| -> Result<T::Balance, DispatchError> { | ||
| let old_free = account.free; | ||
| ensure!(account.reserved == old_reserved, TokenError::Unsupported); | ||
| account.free = new_free; | ||
| Ok(old_free) | ||
| }, | ||
| )?; | ||
|
|
||
| // This will adjust the total issuance, which was not done by the `mutate_account` | ||
| // above. | ||
| if new_free > old_free { | ||
| mem::drop(PositiveImbalance::<T, I>::new(new_free - old_free)); | ||
| } else if new_free < old_free { | ||
| mem::drop(NegativeImbalance::<T, I>::new(old_free - new_free)); | ||
| } | ||
|
|
||
| Self::deposit_event(Event::BalanceSet { who, free: new_free }); | ||
| Ok(()) | ||
| } | ||
|
|
||
| /// Exactly as `transfer_allow_death`, except the origin must be root and the source account | ||
| /// may be specified. | ||
| #[pallet::call_index(2)] | ||
|
|
@@ -730,22 +683,6 @@ pub mod pallet { | |
| } | ||
| } | ||
|
|
||
| /// Alias for `transfer_allow_death`, provided only for name-wise compatibility. | ||
| /// | ||
| /// WARNING: DEPRECATED! Will be released in approximately 3 months. | ||
| #[pallet::call_index(7)] | ||
| #[pallet::weight(T::WeightInfo::transfer_allow_death())] | ||
| pub fn transfer( | ||
| origin: OriginFor<T>, | ||
| dest: AccountIdLookupOf<T>, | ||
| #[pallet::compact] value: T::Balance, | ||
| ) -> DispatchResult { | ||
| let source = ensure_signed(origin)?; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only thing that we could do is to always return an error with a message that the other call should be used.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like we missed an opportunity to mark this function as
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a deprecation message, tagging |
||
| let dest = T::Lookup::lookup(dest)?; | ||
| <Self as fungible::Mutate<_>>::transfer(&source, &dest, value, Expendable)?; | ||
| Ok(()) | ||
| } | ||
|
|
||
| /// Set the regular balance of a given account. | ||
| /// | ||
| /// The dispatch origin for this call is `root`. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.