From 5c2c651eb48c60c56145b27bc428554dd7034b78 Mon Sep 17 00:00:00 2001 From: Igor Kozyrev Date: Thu, 25 Nov 2021 18:36:01 +0000 Subject: [PATCH] Merge branch 'develop' into feature/fix_unit_tests --- --- a/pallets/fungible/src/lib.rs +++ b/pallets/fungible/src/lib.rs @@ -285,7 +285,11 @@ spender: &T::CrossAccountId, amount: u128, ) { - >::insert((collection.id, owner, spender), amount); + if amount == 0 { + >::remove((collection.id, owner, spender)); + } else { + >::insert((collection.id, owner, spender), amount); + } collection.log_infallible(ERC20Events::Approval { owner: *owner.as_eth(), --- 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 = >::get((collection.id, sender)) + .checked_sub(1) + .ok_or(ArithmeticError::Overflow)?; + + if balance == 0 { + >::remove((collection.id, sender)); + } else { + >::insert((collection.id, sender), balance); + } // ========= >::remove((collection.id, &token_data.owner, token)); --- a/pallets/refungible/src/lib.rs +++ b/pallets/refungible/src/lib.rs @@ -175,6 +175,8 @@ >::remove_prefix((id,), None); >::remove_prefix((id,), None); >::remove_prefix((id,), None); + >::remove_prefix((id,), None); + >::remove_prefix((id,), None); Ok(()) } @@ -465,7 +467,11 @@ token: TokenId, amount: u128, ) { - >::insert((collection.id, token, sender, spender), amount); + if amount == 0 { + >::remove((collection.id, token, sender, spender)); + } else { + >::insert((collection.id, token, sender, spender), amount); + } // TODO: ERC20 approval event >::deposit_event(CommonEvent::Approved( collection.id, --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -146,7 +146,7 @@ spec_name: create_runtime_str!("opal"), impl_name: create_runtime_str!("opal"), authoring_version: 1, - spec_version: 912202, + spec_version: 912204, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, -- gitstuff