git.delta.rocks / unique-network / refs/commits / 012bbc1934d8

difftreelog

fix native ft nesting

Trubnikov Sergey2023-05-17parent: #53c316b.patch.diff
in: master

6 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6969,6 +6969,7 @@
  "frame-benchmarking",
  "frame-support",
  "frame-system",
+ "pallet-balances",
  "pallet-common",
  "pallet-evm",
  "pallet-evm-coder-substrate",
modifiedpallets/balances-adapter/src/lib.rsdiffbeforeafterboth
before · pallets/balances-adapter/src/lib.rs
1#![cfg_attr(not(feature = "std"), no_std)]23extern crate alloc;4use core::ops::Deref;56use frame_support::sp_runtime::DispatchResult;7use pallet_evm_coder_substrate::{WithRecorder, SubstrateRecorder};8pub use pallet::*;910pub mod common;11pub mod erc;1213pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;1415/// Handle for native fungible collection16pub struct NativeFungibleHandle<T: Config>(SubstrateRecorder<T>);17impl<T: Config> NativeFungibleHandle<T> {18	/// Creates a handle19	pub fn new() -> NativeFungibleHandle<T> {20		Self(SubstrateRecorder::new(u64::MAX))21	}2223	/// Check if the collection is internal24	pub fn check_is_internal(&self) -> DispatchResult {25		Ok(())26	}27}2829impl<T: Config> WithRecorder<T> for NativeFungibleHandle<T> {30	fn recorder(&self) -> &pallet_evm_coder_substrate::SubstrateRecorder<T> {31		&self.032	}33	fn into_recorder(self) -> pallet_evm_coder_substrate::SubstrateRecorder<T> {34		self.035	}36}3738impl<T: Config> Deref for NativeFungibleHandle<T> {39	type Target = SubstrateRecorder<T>;4041	fn deref(&self) -> &Self::Target {42		&self.043	}44}45#[frame_support::pallet]46pub mod pallet {47	use super::*;48	use alloc::string::String;49	use frame_support::{50		dispatch::PostDispatchInfo,51		ensure,52		pallet_prelude::{DispatchResultWithPostInfo, Pays},53		traits::{Currency, ExistenceRequirement, Get},54	};55	use pallet_balances::WeightInfo;56	use pallet_common::{57		erc::CrossAccountId, Error as CommonError, Pallet as PalletCommon,58		NATIVE_FUNGIBLE_COLLECTION_ID,59	};60	use pallet_structure::Pallet as PalletStructure;61	use sp_core::U256;62	use sp_runtime::DispatchError;63	use up_data_structs::{budget::Budget, mapping::TokenAddressMapping, TokenId};6465	#[pallet::config]66	pub trait Config:67		frame_system::Config68		+ pallet_evm_coder_substrate::Config69		+ pallet_common::Config70		+ pallet_structure::Config71	{72		/// Currency from `pallet_balances`73		type Currency: frame_support::traits::Currency<74			Self::AccountId,75			Balance = Self::CurrencyBalance,76		>;77		/// Balance type of chain78		type CurrencyBalance: Into<U256> + TryFrom<U256> + TryFrom<u128> + Into<u128>;7980		/// Decimals of balance81		type Decimals: Get<u8>;82		/// Collection name83		type Name: Get<String>;84		/// Collection symbol85		type Symbol: Get<String>;8687		/// Weight information88		type WeightInfo: WeightInfo;89	}90	#[pallet::pallet]91	pub struct Pallet<T>(_);9293	impl<T: Config> Pallet<T> {94		/// Checks if a non-owner has (enough) allowance from the owner to perform operations on the tokens.95		/// Returns the expected remaining allowance - it should be set manually if the transaction proceeds.96		///97		/// - `spender`: CrossAccountId who has the allowance rights.98		/// - `from`: The owner of the tokens who sets the allowance.99		/// - `nesting_budget`: Limit for searching parents in-depth to check ownership.100		fn check_allowed(101			spender: &T::CrossAccountId,102			from: &T::CrossAccountId,103			nesting_budget: &dyn Budget,104		) -> Result<u128, DispatchError> {105			if let Some((collection_id, token_id)) =106				T::CrossTokenAddressMapping::address_to_token(from)107			{108				ensure!(109					<PalletStructure<T>>::check_indirectly_owned(110						spender.clone(),111						collection_id,112						token_id,113						None,114						nesting_budget115					)?,116					<CommonError<T>>::ApprovedValueTooLow,117				);118			} else if !spender.conv_eq(from) {119				return Ok(0);120			}121122			Ok(<T as Config>::Currency::free_balance(from.as_sub()).into())123		}124125		/// Transfers the specified amount of tokens. Will check that126		/// the transfer is allowed for the token.127		///128		/// - `collection`: Collection that contains the token.129		/// - `from`: Owner of tokens to transfer.130		/// - `to`: Recepient of transfered tokens.131		/// - `amount`: Amount of tokens to transfer.132		/// - `nesting_budget`: Limit for searching parents in-depth to check ownership.133		pub fn transfer(134			_collection: &NativeFungibleHandle<T>,135			from: &T::CrossAccountId,136			to: &T::CrossAccountId,137			amount: u128,138			nesting_budget: &dyn Budget,139		) -> DispatchResultWithPostInfo {140			<PalletCommon<T>>::ensure_correct_receiver(to)?;141142			if from != to && amount != 0 {143				<T as Config>::Currency::transfer(144					from.as_sub(),145					to.as_sub(),146					amount147						.try_into()148						.map_err(|_| sp_runtime::ArithmeticError::Overflow)?,149					ExistenceRequirement::AllowDeath,150				)?;151152				<PalletStructure<T>>::nest_if_sent_to_token(153					from.clone(),154					to,155					NATIVE_FUNGIBLE_COLLECTION_ID,156					TokenId::default(),157					nesting_budget,158				)?;159160				let balance_from: u128 =161					<T as Config>::Currency::free_balance(from.as_sub()).into();162				if balance_from == 0 {163					<PalletStructure<T>>::unnest_if_nested(164						from,165						NATIVE_FUNGIBLE_COLLECTION_ID,166						TokenId::default(),167					);168				}169			};170171			Ok(PostDispatchInfo {172				actual_weight: Some(<SelfWeightOf<T>>::transfer()),173				pays_fee: Pays::Yes,174			})175		}176177		/// Transfer NFT token from one account to another.178		///179		/// Same as the [`Self::transfer`] but spender doesn't needs to be the owner of the token.180		/// The owner should set allowance for the spender to transfer token.181		///182		/// - `collection`: Collection that contains the token.183		/// - `spender`: Account that spend the money.184		/// - `from`: Owner of tokens to transfer.185		/// - `to`: Recepient of transfered tokens.186		/// - `amount`: Amount of tokens to transfer.187		/// - `nesting_budget`: Limit for searching parents in-depth to check ownership.188		pub fn transfer_from(189			collection: &NativeFungibleHandle<T>,190			spender: &T::CrossAccountId,191			from: &T::CrossAccountId,192			to: &T::CrossAccountId,193			amount: u128,194			nesting_budget: &dyn Budget,195		) -> DispatchResultWithPostInfo {196			let allowance = Self::check_allowed(spender, from, nesting_budget)?;197			if allowance < amount {198				return Err(<CommonError<T>>::ApprovedValueTooLow.into());199			}200			Self::transfer(collection, from, to, amount, nesting_budget)201		}202	}203}
after · pallets/balances-adapter/src/lib.rs
1#![cfg_attr(not(feature = "std"), no_std)]23extern crate alloc;4use core::ops::Deref;56use frame_support::sp_runtime::DispatchResult;7use pallet_evm_coder_substrate::{WithRecorder, SubstrateRecorder};8pub use pallet::*;910pub mod common;11pub mod erc;1213pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;1415/// Handle for native fungible collection16pub struct NativeFungibleHandle<T: Config>(SubstrateRecorder<T>);17impl<T: Config> NativeFungibleHandle<T> {18	/// Creates a handle19	pub fn new() -> NativeFungibleHandle<T> {20		Self(SubstrateRecorder::new(u64::MAX))21	}2223	/// Check if the collection is internal24	pub fn check_is_internal(&self) -> DispatchResult {25		Ok(())26	}27}2829impl<T: Config> WithRecorder<T> for NativeFungibleHandle<T> {30	fn recorder(&self) -> &pallet_evm_coder_substrate::SubstrateRecorder<T> {31		&self.032	}33	fn into_recorder(self) -> pallet_evm_coder_substrate::SubstrateRecorder<T> {34		self.035	}36}3738impl<T: Config> Deref for NativeFungibleHandle<T> {39	type Target = SubstrateRecorder<T>;4041	fn deref(&self) -> &Self::Target {42		&self.043	}44}45#[frame_support::pallet]46pub mod pallet {47	use super::*;48	use alloc::string::String;49	use frame_support::{50		dispatch::PostDispatchInfo,51		ensure,52		pallet_prelude::{DispatchResultWithPostInfo, Pays},53		traits::{Currency, ExistenceRequirement, Get},54	};55	use pallet_balances::WeightInfo;56	use pallet_common::{57		erc::CrossAccountId, Error as CommonError, Pallet as PalletCommon,58		NATIVE_FUNGIBLE_COLLECTION_ID,59	};60	use pallet_structure::Pallet as PalletStructure;61	use sp_core::U256;62	use sp_runtime::DispatchError;63	use up_data_structs::{budget::Budget, mapping::TokenAddressMapping, TokenId};6465	#[pallet::config]66	pub trait Config:67		frame_system::Config68		+ pallet_evm_coder_substrate::Config69		+ pallet_common::Config70		+ pallet_structure::Config71	{72		/// Currency from `pallet_balances`73		type Currency: frame_support::traits::Currency<74			Self::AccountId,75			Balance = Self::CurrencyBalance,76		>;77		/// Balance type of chain78		type CurrencyBalance: Into<U256> + TryFrom<U256> + TryFrom<u128> + Into<u128>;7980		/// Decimals of balance81		type Decimals: Get<u8>;82		/// Collection name83		type Name: Get<String>;84		/// Collection symbol85		type Symbol: Get<String>;8687		/// Weight information88		type WeightInfo: WeightInfo;89	}90	#[pallet::pallet]91	pub struct Pallet<T>(_);9293	impl<T: Config> Pallet<T> {94		/// Checks if a non-owner has (enough) allowance from the owner to perform operations on the tokens.95		/// Returns the expected remaining allowance - it should be set manually if the transaction proceeds.96		///97		/// - `spender`: CrossAccountId who has the allowance rights.98		/// - `from`: The owner of the tokens who sets the allowance.99		/// - `nesting_budget`: Limit for searching parents in-depth to check ownership.100		fn check_allowed(101			spender: &T::CrossAccountId,102			from: &T::CrossAccountId,103			nesting_budget: &dyn Budget,104		) -> Result<u128, DispatchError> {105			if let Some((collection_id, token_id)) =106				T::CrossTokenAddressMapping::address_to_token(from)107			{108				ensure!(109					<PalletStructure<T>>::check_indirectly_owned(110						spender.clone(),111						collection_id,112						token_id,113						None,114						nesting_budget115					)?,116					<CommonError<T>>::ApprovedValueTooLow,117				);118			} else if !spender.conv_eq(from) {119				return Ok(0);120			}121122			Ok(<T as Config>::Currency::free_balance(from.as_sub()).into())123		}124125		/// Transfers the specified amount of tokens. Will check that126		/// the transfer is allowed for the token.127		///128		/// - `collection`: Collection that contains the token.129		/// - `from`: Owner of tokens to transfer.130		/// - `to`: Recepient of transfered tokens.131		/// - `amount`: Amount of tokens to transfer.132		/// - `nesting_budget`: Limit for searching parents in-depth to check ownership.133		pub fn transfer(134			_collection: &NativeFungibleHandle<T>,135			from: &T::CrossAccountId,136			to: &T::CrossAccountId,137			amount: u128,138			nesting_budget: &dyn Budget,139		) -> DispatchResultWithPostInfo {140			<PalletCommon<T>>::ensure_correct_receiver(to)?;141142			if from != to && amount != 0 {143				<T as Config>::Currency::transfer(144					from.as_sub(),145					to.as_sub(),146					amount147						.try_into()148						.map_err(|_| sp_runtime::ArithmeticError::Overflow)?,149					ExistenceRequirement::AllowDeath,150				)?;151			};152153			Ok(PostDispatchInfo {154				actual_weight: Some(<SelfWeightOf<T>>::transfer()),155				pays_fee: Pays::Yes,156			})157		}158159		/// Transfer NFT token from one account to another.160		///161		/// Same as the [`Self::transfer`] but spender doesn't needs to be the owner of the token.162		/// The owner should set allowance for the spender to transfer token.163		///164		/// - `collection`: Collection that contains the token.165		/// - `spender`: Account that spend the money.166		/// - `from`: Owner of tokens to transfer.167		/// - `to`: Recepient of transfered tokens.168		/// - `amount`: Amount of tokens to transfer.169		/// - `nesting_budget`: Limit for searching parents in-depth to check ownership.170		pub fn transfer_from(171			collection: &NativeFungibleHandle<T>,172			spender: &T::CrossAccountId,173			from: &T::CrossAccountId,174			to: &T::CrossAccountId,175			amount: u128,176			nesting_budget: &dyn Budget,177		) -> DispatchResultWithPostInfo {178			let allowance = Self::check_allowed(spender, from, nesting_budget)?;179			if allowance < amount {180				return Err(<CommonError<T>>::ApprovedValueTooLow.into());181			}182			Self::transfer(collection, from, to, amount, nesting_budget)183		}184	}185}
modifiedpallets/nonfungible/Cargo.tomldiffbeforeafterboth
--- a/pallets/nonfungible/Cargo.toml
+++ b/pallets/nonfungible/Cargo.toml
@@ -12,6 +12,7 @@
 frame-benchmarking = { workspace = true, optional = true }
 frame-support = { workspace = true }
 frame-system = { workspace = true }
+pallet-balances = { workspace = true }
 pallet-common = { workspace = true }
 pallet-evm = { workspace = true }
 pallet-evm-coder-substrate = { workspace = true }
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -166,7 +166,11 @@
 
 	#[pallet::config]
 	pub trait Config:
-		frame_system::Config + pallet_common::Config + pallet_structure::Config + pallet_evm::Config
+		frame_system::Config
+		+ pallet_common::Config
+		+ pallet_structure::Config
+		+ pallet_evm::Config
+		+ pallet_balances::Config
 	{
 		type WeightInfo: WeightInfo;
 	}
@@ -1325,11 +1329,15 @@
 	}
 
 	fn nest(under: (CollectionId, TokenId), to_nest: (CollectionId, TokenId)) {
-		<TokenChildren<T>>::insert((under.0, under.1, (to_nest.0, to_nest.1)), true);
+		if to_nest.0 != pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {
+			<TokenChildren<T>>::insert((under.0, under.1, to_nest), true);
+		}
 	}
 
 	fn unnest(under: (CollectionId, TokenId), to_unnest: (CollectionId, TokenId)) {
-		<TokenChildren<T>>::remove((under.0, under.1, to_unnest));
+		if to_unnest.0 != pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {
+			<TokenChildren<T>>::remove((under.0, under.1, to_unnest));
+		}
 	}
 
 	fn collection_has_tokens(collection_id: CollectionId) -> bool {
@@ -1339,18 +1347,37 @@
 	}
 
 	fn token_has_children(collection_id: CollectionId, token_id: TokenId) -> bool {
-		<TokenChildren<T>>::iter_prefix((collection_id, token_id))
-			.next()
-			.is_some()
+		let address = T::CrossTokenAddressMapping::token_to_address(collection_id, token_id);
+		let balance = <pallet_balances::Pallet<T>>::free_balance(address.as_sub());
+
+		balance > T::Balance::default()
+			|| <TokenChildren<T>>::iter_prefix((collection_id, token_id))
+				.next()
+				.is_some()
 	}
 
 	pub fn token_children_ids(collection_id: CollectionId, token_id: TokenId) -> Vec<TokenChild> {
-		<TokenChildren<T>>::iter_prefix((collection_id, token_id))
-			.map(|((child_collection_id, child_id), _)| TokenChild {
-				collection: child_collection_id,
-				token: child_id,
+		let mut tokens: Vec<_> = vec![];
+
+		let address = T::CrossTokenAddressMapping::token_to_address(collection_id, token_id);
+		let balance = <pallet_balances::Pallet<T>>::free_balance(address.as_sub());
+		if balance > T::Balance::default() {
+			tokens.push(TokenChild {
+				token: TokenId(0),
+				collection: pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID,
 			})
-			.collect()
+		}
+
+		tokens.extend(
+			<TokenChildren<T>>::iter_prefix((collection_id, token_id)).map(
+				|((child_collection_id, child_id), _)| TokenChild {
+					collection: child_collection_id,
+					token: child_id,
+				},
+			),
+		);
+
+		tokens
 	}
 
 	/// Mint single NFT token.
modifiedtests/src/eth/nesting/nest.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nesting/nest.test.ts
+++ b/tests/src/eth/nesting/nest.test.ts
@@ -248,7 +248,7 @@
       {mode: 'ft' as const},
       {mode: 'native ft' as const},
     ].map(testCase => {
-      itEth(`Disallow nest into collection without nesting permission [${testCase.mode}]`, async ({helper}) => {
+      itEth(`Disallow nest into collection without nesting permission [${testCase.mode}] (except for native fungible collection)`, async ({helper}) => {
         const owner = await helper.eth.createAccountWithBalance(donor);
         const {collectionId: targetCollectionId, contract: targetContract} = await createNestingCollection(helper, owner);
         await targetContract.methods.setCollectionNesting(false).send({from: owner});
@@ -259,7 +259,11 @@
         const targetTokenId = mintingTargetTokenIdResult.events.Transfer.returnValues.tokenId;
         const targetTokenAddress = helper.ethAddress.fromTokenId(targetCollectionId, targetTokenId);
 
-        await expect(ftContract.methods.transfer(targetTokenAddress, 10n).call({from: owner})).to.be.rejectedWith('UserIsNotAllowedToNest');
+        if (testCase.mode === 'ft') {
+          await expect(ftContract.methods.transfer(targetTokenAddress, 10n).call({from: owner})).to.be.rejectedWith('UserIsNotAllowedToNest');
+        } else {
+          await expect(ftContract.methods.transfer(targetTokenAddress, 10n).call({from: owner})).to.be.not.rejected;
+        }
       });
     });
   });
modifiedtests/src/sub/nesting/nesting.negative.test.tsdiffbeforeafterboth
--- a/tests/src/sub/nesting/nesting.negative.test.ts
+++ b/tests/src/sub/nesting/nesting.negative.test.ts
@@ -58,7 +58,7 @@
     {mode: 'ft'},
     {mode: 'nativeFt'},
   ].map(testCase => {
-    itSub(`Owner cannot nest [${testCase.mode}] if nesting is disabled`, async ({helper}) => {
+    itSub(`Owner cannot nest [${testCase.mode}] if nesting is disabled (except for native fungible collection)`, async ({helper}) => {
     // Create default collection, permissions are not set:
       const aliceNFTCollection = await helper.nft.mintCollection(alice);
       const targetToken = await aliceNFTCollection.mintToken(alice);
@@ -66,15 +66,22 @@
       const collectionForNesting = testCase.mode === 'ft' ? await helper.ft.mintCollection(alice) : helper.ft.getCollectionObject(0);
 
       // Alice cannot create immediately nested tokens:
-      await expect(testCase.mode === 'ft'
-        ? collectionForNesting.mint(alice, 100n, targetToken.nestingAccount())
-        : collectionForNesting.transfer(alice, targetToken.nestingAccount(), 100n)).to.be.rejectedWith('common.UserIsNotAllowedToNest');
+      if (testCase.mode === 'ft') {
+        await expect(collectionForNesting.mint(alice, 100n, targetToken.nestingAccount())).to.be.rejectedWith('common.UserIsNotAllowedToNest');
+      } else {
+        await expect(collectionForNesting.transfer(alice, targetToken.nestingAccount(), 100n)).to.be.not.rejected;
+      }
 
       // Alice can't mint and nest tokens:
       if (testCase.mode === 'ft') {
         await collectionForNesting.mint(alice, 100n);
       }
-      await expect(collectionForNesting.transfer(alice, targetToken.nestingAccount(), 50n)).to.be.rejectedWith('common.UserIsNotAllowedToNest');
+
+      if (testCase.mode === 'ft') {
+        await expect(collectionForNesting.transfer(alice, targetToken.nestingAccount(), 50n)).to.be.rejectedWith('common.UserIsNotAllowedToNest');
+      } else {
+        await expect(collectionForNesting.transfer(alice, targetToken.nestingAccount(), 50n)).to.be.not.rejected;
+      }
     });
   });
 
@@ -84,7 +91,7 @@
     {mode: 'ft' as const},
     {mode: 'native ft' as const},
   ].map(testCase => {
-    itSub(`Non-owner and non-admin cannot nest ${testCase.mode.toUpperCase()} in someone else's tokens`, async ({helper}) => {
+    itSub(`Non-owner and non-admin cannot nest ${testCase.mode.toUpperCase()} in someone else's tokens (except for native fungible collection)`, async ({helper}) => {
       const targetCollection = await helper.nft.mintCollection(alice, {permissions:
         {nesting: {tokenOwner: true, collectionAdmin: true}},
       });
@@ -118,7 +125,7 @@
         case 'nft':
         case 'rft': await expect(nestedTokenBob!.transfer(bob, targetToken.nestingAccount())).to.be.rejectedWith('common.UserIsNotAllowedToNest'); break;
         case 'ft': await expect((nestedCollectionBob as UniqueFTCollection).transfer(bob, targetToken.nestingAccount(), 100n)).to.be.rejectedWith('common.UserIsNotAllowedToNest'); break;
-        case 'native ft': await expect((nestedCollectionBob as UniqueFTCollection).transfer(bob, targetToken.nestingAccount(), 100n)).to.be.rejectedWith('common.UserIsNotAllowedToNest'); break;
+        case 'native ft': await expect((nestedCollectionBob as UniqueFTCollection).transfer(bob, targetToken.nestingAccount(), 100n)).to.be.not.rejected; break;
       }
     });
   });
@@ -143,7 +150,7 @@
     });
   });
 
-  itSub.ifWithPallets('Cannot nest in non existing token', [Pallets.ReFungible], async ({helper}) => {
+  itSub.ifWithPallets('Cannot nest in non existing token (except for native fungible collection)', [Pallets.ReFungible], async ({helper}) => {
     const collection = await helper.nft.mintCollection(alice);
     // To avoid UserIsNotAllowedToNest error
     await helper.collection.setPermissions(alice, collection.collectionId, {nesting: {collectionAdmin: true}});
@@ -179,7 +186,7 @@
       await expect(nft.transfer(alice, testCase.token.nestingAccount())).to.be.rejectedWith(testCase.error);
       await expect(rft.transfer(alice, testCase.token.nestingAccount())).to.be.rejectedWith(testCase.error);
       await expect(ftCollectionForNesting.transfer(alice, testCase.token.nestingAccount(), 50n)).to.be.rejectedWith(testCase.error);
-      await expect(nativeFtCollectionForNesting.transfer(alice, testCase.token.nestingAccount(), 50n)).to.be.rejectedWith(testCase.error);
+      await expect(nativeFtCollectionForNesting.transfer(alice, testCase.token.nestingAccount(), 50n)).to.be.not.rejected;
     }
   });
 
@@ -200,7 +207,7 @@
     await expect(nft.transfer(alice, {Ethereum: futureCollectionAddress})).to.be.rejectedWith('CantNestTokenUnderCollection');
   });
 
-  itEth.ifWithPallets('Cannot nest in RFT or FT', [Pallets.ReFungible], async ({helper}) => {
+  itEth.ifWithPallets('Cannot nest in RFT or FT (except for native fungible collection)', [Pallets.ReFungible], async ({helper}) => {
     // Create default collection, permissions are not set:
     const rftCollection = await helper.rft.mintCollection(alice);
     const ftCollection = await helper.ft.mintCollection(alice);
@@ -220,15 +227,15 @@
     const nestedToken2 = await collectionForNesting.mintToken(alice);
     await expect(nestedToken2.nest(alice, rftToken)).to.be.rejectedWith('refungible.RefungibleDisallowsNesting');
     await expect(ftCollection.transfer(alice, {Ethereum: helper.ethAddress.fromTokenId(ftCollection.collectionId, 0)})).to.be.rejectedWith('fungible.FungibleDisallowsNesting');
-    await expect(nativeFtCollection.transfer(alice, {Ethereum: helper.ethAddress.fromTokenId(nativeFtCollection.collectionId, 0)})).to.be.rejectedWith('common.UnsupportedOperation');
+    await expect(nativeFtCollection.transfer(alice, {Ethereum: helper.ethAddress.fromTokenId(nativeFtCollection.collectionId, 0)})).to.be.not.rejected;
   });
 
-  itSub('Cannot nest in restricted collection if collection is not in the list', async ({helper}) => {
+  itSub('Cannot nest in restricted collection if collection is not in the list (except native fungible collection)', async ({helper}) => {
     const {collectionId: allowedCollectionId} = await helper.nft.mintCollection(alice);
     const notAllowedCollectionNFT = await helper.nft.mintCollection(alice);
     const notAllowedCollectionRFT = await helper.rft.mintCollection(alice);
     const notAllowedCollectionFT = await helper.ft.mintCollection(alice);
-    const notAllowedCollectionNativeFT = helper.ft.getCollectionObject(0);
+    const allowedCollectionNativeFT = helper.ft.getCollectionObject(0);
 
     // Collection restricted to allowedCollectionId
     const restrictedCollectionA = await helper.nft.mintCollection(alice, {permissions:
@@ -253,8 +260,8 @@
     await expect(notAllowedCollectionRFT.mintToken(alice, 100n, targetTokenB.nestingAccount())).to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
     await expect(notAllowedCollectionFT.mint(alice, 100n, targetTokenA.nestingAccount())).to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
     await expect(notAllowedCollectionFT.mint(alice, 100n, targetTokenB.nestingAccount())).to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
-    await expect(notAllowedCollectionNativeFT.transfer(alice, targetTokenA.nestingAccount(), 100n)).to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
-    await expect(notAllowedCollectionNativeFT.transfer(alice, targetTokenB.nestingAccount(), 100n)).to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
+    await expect(allowedCollectionNativeFT.transfer(alice, targetTokenA.nestingAccount(), 100n)).to.be.not.rejected;
+    await expect(allowedCollectionNativeFT.transfer(alice, targetTokenB.nestingAccount(), 100n)).to.be.not.rejected;
   });
 
   itSub('Cannot create nesting chains greater than 5', async ({helper}) => {