git.delta.rocks / unique-network / refs/commits / 2880b7f76c03

difftreelog

fix zero transfer

PraetorP2022-12-05parent: #1c47062.patch.diff
in: master

13 files changed

modifiedCargo.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",
modifiedpallets/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
modifiedpallets/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"
 
modifiedpallets/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.
modifiedpallets/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
modifiedpallets/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"
 
modifiedpallets/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,
modifiedpallets/nonfungible/CHANGELOG.mddiffbeforeafterboth
before · pallets/nonfungible/CHANGELOG.md
1# Change Log23All notable changes to this project will be documented in this file.45<!-- bureaucrate goes here -->67## [0.1.10] - 2022-11-1889### Added1011- The functions `description`, `crossOwnerOf`, `tokenProperties` to `ERC721UniqueExtensions` interface.1213## [0.1.9] - 2022-11-141415### Changed1617- Added `transfer_cross` in eth functions.1819## [v0.1.8] - 2022-11-112021### Changed2223- Added `delete_properties` in eth functions. The `delete_property` function is now deprecated.2425## [v0.1.7] - 2022-11-022627### Changed2829- Use named structure `EthCrossAccount` in eth functions.3031## [v0.1.6] - 2022-20-103233### Change3435- Added `set_properties` method for `TokenProperties` interface.3637## [v0.1.5] - 2022-08-243839### Change4041- Add bound `AsRef<[u8; 32]>` to `T::CrossAccountId`.4243## [v0.1.4] 2022-08-164445### Other changes4647- build: Upgrade polkadot to v0.9.27 2c498572636f2b34d53b1c51b7283a761a7dc90a4849- build: Upgrade polkadot to v0.9.26 85515e54c4ca1b82a2630034e55dcc804c643bf85051- refactor: Switch to new prefix removal methods 26734e9567589d75cdd99e404eabf11d5a97d9755253New methods allows to call `remove_prefix` with limit multiple times54in the same block55However, we don't use prefix removal limits, so upgrade is56straightforward5758Upstream-Change: https://github.com/paritytech/substrate/pull/114905960- build: Upgrade polkadot to v0.9.25 cdfb9bdc7b205ff1b5134f034ef9973d769e5e6b6162## [0.1.2] - 2022-07-256364### Changed6566- New `token_uri` retrieval logic:6768      If the collection has a `url` property and it is not empty, it is returned.69      Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.7071      If the property `baseURI` is empty or absent, return "" (empty string)72      otherwise, if property `suffix` present and is non-empty, return concatenation of baseURI and suffix73      otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).7475## [0.1.1] - 2022-07-147677### Added7879- Implementation of RPC method `token_owners`.80  For reasons of compatibility with this pallet, returns only one owner if token exists.81  This was an internal request to improve the web interface and support fractionalization event.
after · pallets/nonfungible/CHANGELOG.md
1# Change Log23All notable changes to this project will be documented in this file.45<!-- bureaucrate goes here -->67## [0.1.11] - 2022-12-0589### Fixed1011- Transfer with zero tokens.1213## [0.1.10] - 2022-11-181415### Added1617- The functions `description`, `crossOwnerOf`, `tokenProperties` to `ERC721UniqueExtensions` interface.1819## [0.1.9] - 2022-11-142021### Changed2223- Added `transfer_cross` in eth functions.2425## [v0.1.8] - 2022-11-112627### Changed2829- Added `delete_properties` in eth functions. The `delete_property` function is now deprecated.3031## [v0.1.7] - 2022-11-023233### Changed3435- Use named structure `EthCrossAccount` in eth functions.3637## [v0.1.6] - 2022-20-103839### Change4041- Added `set_properties` method for `TokenProperties` interface.4243## [v0.1.5] - 2022-08-244445### Change4647- Add bound `AsRef<[u8; 32]>` to `T::CrossAccountId`.4849## [v0.1.4] 2022-08-165051### Other changes5253- build: Upgrade polkadot to v0.9.27 2c498572636f2b34d53b1c51b7283a761a7dc90a5455- build: Upgrade polkadot to v0.9.26 85515e54c4ca1b82a2630034e55dcc804c643bf85657- refactor: Switch to new prefix removal methods 26734e9567589d75cdd99e404eabf11d5a97d9755859New methods allows to call `remove_prefix` with limit multiple times60in the same block61However, we don't use prefix removal limits, so upgrade is62straightforward6364Upstream-Change: https://github.com/paritytech/substrate/pull/114906566- build: Upgrade polkadot to v0.9.25 cdfb9bdc7b205ff1b5134f034ef9973d769e5e6b6768## [0.1.2] - 2022-07-256970### Changed7172- New `token_uri` retrieval logic:7374      If the collection has a `url` property and it is not empty, it is returned.75      Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.7677      If the property `baseURI` is empty or absent, return "" (empty string)78      otherwise, if property `suffix` present and is non-empty, return concatenation of baseURI and suffix79      otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).8081## [0.1.1] - 2022-07-148283### Added8485- Implementation of RPC method `token_owners`.86  For reasons of compatibility with this pallet, returns only one owner if token exists.87  This was an internal request to improve the web interface and support fractionalization event.
modifiedpallets/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"
 
modifiedpallets/nonfungible/src/common.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -23,7 +23,7 @@
 };
 use pallet_common::{
 	CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions, with_weight,
-	weights::WeightInfo as _,
+	weights::WeightInfo as _, Error as CommonError,
 };
 use sp_runtime::DispatchError;
 use sp_std::{vec::Vec, vec};
@@ -314,14 +314,12 @@
 		nesting_budget: &dyn Budget,
 	) -> DispatchResultWithPostInfo {
 		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);
-		if amount == 1 {
-			with_weight(
-				<Pallet<T>>::transfer(self, &from, &to, token, nesting_budget),
-				<CommonWeights<T>>::transfer(),
-			)
-		} else {
-			Ok(().into())
-		}
+		ensure!(amount > 0, <CommonError<T>>::ZeroTransferNotAllowed);
+
+		with_weight(
+			<Pallet<T>>::transfer(self, &from, &to, token, nesting_budget),
+			<CommonWeights<T>>::transfer(),
+		)
 	}
 
 	fn approve(
@@ -353,15 +351,12 @@
 		nesting_budget: &dyn Budget,
 	) -> DispatchResultWithPostInfo {
 		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);
+		ensure!(amount > 0, <CommonError<T>>::ZeroTransferNotAllowed);
 
-		if amount == 1 {
-			with_weight(
-				<Pallet<T>>::transfer_from(self, &sender, &from, &to, token, nesting_budget),
-				<CommonWeights<T>>::transfer_from(),
-			)
-		} else {
-			Ok(().into())
-		}
+		with_weight(
+			<Pallet<T>>::transfer_from(self, &sender, &from, &to, token, nesting_budget),
+			<CommonWeights<T>>::transfer_from(),
+		)
 	}
 
 	fn burn_from(
modifiedpallets/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
 
modifiedpallets/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"
 
modifiedpallets/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