difftreelog
fix zero transfer
in: master
13 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5901,7 +5901,7 @@
[[package]]
name = "pallet-common"
-version = "0.1.12"
+version = "0.1.13"
dependencies = [
"ethereum",
"evm-coder",
@@ -6191,7 +6191,7 @@
[[package]]
name = "pallet-fungible"
-version = "0.1.7"
+version = "0.1.8"
dependencies = [
"ethereum",
"evm-coder",
@@ -6446,7 +6446,7 @@
[[package]]
name = "pallet-nonfungible"
-version = "0.1.9"
+version = "0.1.10"
dependencies = [
"ethereum",
"evm-coder",
@@ -6568,7 +6568,7 @@
[[package]]
name = "pallet-refungible"
-version = "0.2.8"
+version = "0.2.9"
dependencies = [
"derivative",
"ethereum",
pallets/common/CHANGELOG.mddiffbeforeafterboth--- a/pallets/common/CHANGELOG.md
+++ b/pallets/common/CHANGELOG.md
@@ -4,6 +4,12 @@
<!-- bureaucrate goes here -->
+## [0.1.13] - 2022-12-05
+
+### Added
+
+- The error `ZeroTransferNotAllowed` to handling transactions with the transfer of a zero amount of tokens.
+
## [0.1.12] - 2022-11-16
### Changed
pallets/common/Cargo.tomldiffbeforeafterboth--- a/pallets/common/Cargo.toml
+++ b/pallets/common/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "pallet-common"
-version = "0.1.12"
+version = "0.1.13"
license = "GPLv3"
edition = "2021"
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -601,6 +601,9 @@
/// Tried to access an internal collection with an external API
CollectionIsInternal,
+
+ /// Transfer operation with zero amount
+ ZeroTransferNotAllowed,
}
/// Storage of the count of created collections. Essentially contains the last collection ID.
pallets/fungible/CHANGELOG.mddiffbeforeafterboth--- a/pallets/fungible/CHANGELOG.md
+++ b/pallets/fungible/CHANGELOG.md
@@ -4,6 +4,12 @@
<!-- bureaucrate goes here -->
+## [0.1.9] - 2022-12-05
+
+### Fixed
+
+- Transfer with zero tokens.
+
## [0.1.8] - 2022-11-18
### Added
pallets/fungible/Cargo.tomldiffbeforeafterboth--- a/pallets/fungible/Cargo.toml
+++ b/pallets/fungible/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "pallet-fungible"
-version = "0.1.7"
+version = "0.1.8"
license = "GPLv3"
edition = "2021"
pallets/fungible/src/lib.rsdiffbeforeafterboth--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -365,6 +365,8 @@
amount: u128,
nesting_budget: &dyn Budget,
) -> DispatchResult {
+ ensure!(amount > 0, <CommonError<T>>::ZeroTransferNotAllowed);
+
ensure!(
collection.limits.transfers_enabled(),
<CommonError<T>>::TransferNotAllowed,
pallets/nonfungible/CHANGELOG.mddiffbeforeafterboth--- a/pallets/nonfungible/CHANGELOG.md
+++ b/pallets/nonfungible/CHANGELOG.md
@@ -4,6 +4,12 @@
<!-- bureaucrate goes here -->
+## [0.1.11] - 2022-12-05
+
+### Fixed
+
+- Transfer with zero tokens.
+
## [0.1.10] - 2022-11-18
### Added
pallets/nonfungible/Cargo.tomldiffbeforeafterboth--- a/pallets/nonfungible/Cargo.toml
+++ b/pallets/nonfungible/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "pallet-nonfungible"
-version = "0.1.9"
+version = "0.1.10"
license = "GPLv3"
edition = "2021"
pallets/nonfungible/src/common.rsdiffbeforeafterboth23};23};24use pallet_common::{24use pallet_common::{25 CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions, with_weight,25 CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions, with_weight,26 weights::WeightInfo as _,26 weights::WeightInfo as _, Error as CommonError,27};27};28use sp_runtime::DispatchError;28use sp_runtime::DispatchError;29use sp_std::{vec::Vec, vec};29use sp_std::{vec::Vec, vec};314 nesting_budget: &dyn Budget,314 nesting_budget: &dyn Budget,315 ) -> DispatchResultWithPostInfo {315 ) -> DispatchResultWithPostInfo {316 ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);316 ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);317 if amount == 1 {317 ensure!(amount > 0, <CommonError<T>>::ZeroTransferNotAllowed);318318 with_weight(319 with_weight(319 <Pallet<T>>::transfer(self, &from, &to, token, nesting_budget),320 <Pallet<T>>::transfer(self, &from, &to, token, nesting_budget),320 <CommonWeights<T>>::transfer(),321 <CommonWeights<T>>::transfer(),321 )322 )322 } else {323 Ok(().into())324 }325 }323 }326324327 fn approve(325 fn approve(354 ) -> DispatchResultWithPostInfo {352 ) -> DispatchResultWithPostInfo {355 ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);353 ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);356357 if amount == 1 {354 ensure!(amount > 0, <CommonError<T>>::ZeroTransferNotAllowed);355358 with_weight(356 with_weight(359 <Pallet<T>>::transfer_from(self, &sender, &from, &to, token, nesting_budget),357 <Pallet<T>>::transfer_from(self, &sender, &from, &to, token, nesting_budget),360 <CommonWeights<T>>::transfer_from(),358 <CommonWeights<T>>::transfer_from(),361 )359 )362 } else {363 Ok(().into())364 }365 }360 }366361367 fn burn_from(362 fn burn_from(pallets/refungible/CHANGELOG.mddiffbeforeafterboth--- a/pallets/refungible/CHANGELOG.md
+++ b/pallets/refungible/CHANGELOG.md
@@ -3,6 +3,11 @@
All notable changes to this project will be documented in this file.
<!-- bureaucrate goes here -->
+## [0.2.10] - 2022-12-05
+
+### Fixed
+
+- Transfer with zero pieces.
## [0.2.9] - 2022-11-18
pallets/refungible/Cargo.tomldiffbeforeafterboth--- a/pallets/refungible/Cargo.toml
+++ b/pallets/refungible/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "pallet-refungible"
-version = "0.2.8"
+version = "0.2.9"
license = "GPLv3"
edition = "2021"
pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -727,6 +727,8 @@
amount: u128,
nesting_budget: &dyn Budget,
) -> DispatchResult {
+ ensure!(amount > 0, <CommonError<T>>::ZeroTransferNotAllowed);
+
ensure!(
collection.limits.transfers_enabled(),
<CommonError<T>>::TransferNotAllowed