-
Notifications
You must be signed in to change notification settings - Fork 300
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
Implement fungible and fungibles for tokens #517
Conversation
tokens/src/lib.rs
Outdated
source: &T::AccountId, | ||
dest: &T::AccountId, | ||
amount: T::Balance, | ||
_keep_alive: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we shouldn't ignore keep_alive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
open-runtime-module-library/tokens/src/lib.rs
Lines 519 to 538 in 7cd2c10
fn transfer( | |
currency_id: Self::CurrencyId, | |
from: &T::AccountId, | |
to: &T::AccountId, | |
amount: Self::Balance, | |
) -> DispatchResult { | |
if amount.is_zero() || from == to { | |
return Ok(()); | |
} | |
Self::ensure_can_withdraw(currency_id, from, amount)?; | |
let from_balance = Self::free_balance(currency_id, from); | |
let to_balance = Self::free_balance(currency_id, to) | |
.checked_add(&amount) | |
.ok_or(ArithmeticError::Overflow)?; | |
// Cannot underflow because ensure_can_withdraw check | |
Self::set_free_balance(currency_id, from, from_balance - amount); | |
Self::set_free_balance(currency_id, to, to_balance); | |
Ok(()) |
Tokens
transfer
not handle the ExistenceRequirement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need a version that handles it, and transfer
can call it with keep_alive: false
traits/src/currency.rs
Outdated
from: &AccountId, | ||
to: &AccountId, | ||
amount: Self::Balance, | ||
existence_requirement: ExistenceRequirement, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will break too many existing code.
I was thinking only update the transfer implementation of orml-tokens. Add a new helper method to take existence_requirement.
traits/src/currency.rs
Outdated
@@ -49,6 +49,7 @@ pub trait MultiCurrency<AccountId> { | |||
from: &AccountId, | |||
to: &AccountId, | |||
amount: Self::Balance, | |||
existence_requirement: ExistenceRequirement, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this as well
#417
currencies module is updating.