difftreelog
Merge branch 'develop' into feature/fix_unit_tests
in: master
4 files changed
pallets/fungible/src/lib.rsdiffbeforeafterboth--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -285,7 +285,11 @@
spender: &T::CrossAccountId,
amount: u128,
) {
- <Allowance<T>>::insert((collection.id, owner, spender), amount);
+ if amount == 0 {
+ <Allowance<T>>::remove((collection.id, owner, spender));
+ } else {
+ <Allowance<T>>::insert((collection.id, owner, spender), amount);
+ }
collection.log_infallible(ERC20Events::Approval {
owner: *owner.as_eth(),
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -177,6 +177,15 @@
.checked_add(1)
.ok_or(ArithmeticError::Overflow)?;
+ let balance = <AccountBalance<T>>::get((collection.id, sender))
+ .checked_sub(1)
+ .ok_or(ArithmeticError::Overflow)?;
+
+ if balance == 0 {
+ <AccountBalance<T>>::remove((collection.id, sender));
+ } else {
+ <AccountBalance<T>>::insert((collection.id, sender), balance);
+ }
// =========
<Owned<T>>::remove((collection.id, &token_data.owner, token));
pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -175,6 +175,8 @@
<TotalSupply<T>>::remove_prefix((id,), None);
<Balance<T>>::remove_prefix((id,), None);
<Allowance<T>>::remove_prefix((id,), None);
+ <Owned<T>>::remove_prefix((id,), None);
+ <AccountBalance<T>>::remove_prefix((id,), None);
Ok(())
}
@@ -465,7 +467,11 @@
token: TokenId,
amount: u128,
) {
- <Allowance<T>>::insert((collection.id, token, sender, spender), amount);
+ if amount == 0 {
+ <Allowance<T>>::remove((collection.id, token, sender, spender));
+ } else {
+ <Allowance<T>>::insert((collection.id, token, sender, spender), amount);
+ }
// TODO: ERC20 approval event
<PalletCommon<T>>::deposit_event(CommonEvent::Approved(
collection.id,
runtime/src/lib.rsdiffbeforeafterboth146 spec_name: create_runtime_str!("opal"),146 spec_name: create_runtime_str!("opal"),147 impl_name: create_runtime_str!("opal"),147 impl_name: create_runtime_str!("opal"),148 authoring_version: 1,148 authoring_version: 1,149 spec_version: 912202,149 spec_version: 912204,150 impl_version: 1,150 impl_version: 1,151 apis: RUNTIME_API_VERSIONS,151 apis: RUNTIME_API_VERSIONS,152 transaction_version: 1,152 transaction_version: 1,