git.delta.rocks / unique-network / refs/commits / fa10a01fefef

difftreelog

Merge branch 'develop' into tests/generalization

Max Andreev2023-01-13parents: #b0a74de #46515fa.patch.diff
in: master

33 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2321,7 +2321,7 @@
 
 [[package]]
 name = "evm-coder"
-version = "0.1.5"
+version = "0.1.6"
 dependencies = [
  "ethereum 0.14.0",
  "evm-coder-procedural",
modifiedcrates/evm-coder/CHANGELOG.mddiffbeforeafterboth
--- a/crates/evm-coder/CHANGELOG.md
+++ b/crates/evm-coder/CHANGELOG.md
@@ -3,6 +3,13 @@
 All notable changes to this project will be documented in this file.
 
 <!-- bureaucrate goes here -->
+## [v0.1.6] - 2023-01-12
+
+### Added
+- Support Option<T> type.
+### Removed
+- Frontier dependency.
+
 ## [v0.1.5] - 2022-11-30
 
 ### Added
modifiedcrates/evm-coder/Cargo.tomldiffbeforeafterboth
--- a/crates/evm-coder/Cargo.toml
+++ b/crates/evm-coder/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "evm-coder"
-version = "0.1.5"
+version = "0.1.6"
 license = "GPLv3"
 edition = "2021"
 
modifiedcrates/evm-coder/src/abi/impls.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/abi/impls.rs
+++ b/crates/evm-coder/src/abi/impls.rs
@@ -258,3 +258,39 @@
 impl_tuples! {A B C D E F G H}
 impl_tuples! {A B C D E F G H I}
 impl_tuples! {A B C D E F G H I J}
+
+//----- impls for Option -----
+impl<T: AbiType> AbiType for Option<T> {
+	const SIGNATURE: SignatureUnit = <(bool, T)>::SIGNATURE;
+
+	fn is_dynamic() -> bool {
+		<(bool, T)>::is_dynamic()
+	}
+
+	fn size() -> usize {
+		<(bool, T)>::size()
+	}
+}
+
+impl<T: AbiWrite + AbiType + Default> AbiWrite for Option<T> {
+	fn abi_write(&self, writer: &mut AbiWriter) {
+		match self {
+			Some(value) => (true, value).abi_write(writer),
+			None => (false, T::default()).abi_write(writer),
+		}
+	}
+}
+
+impl<T> AbiRead for Option<T>
+where
+	Self: AbiType,
+	T: AbiRead + AbiType,
+{
+	fn abi_read(reader: &mut AbiReader) -> Result<Self>
+	where
+		Self: Sized,
+	{
+		let (status, value) = <(bool, T)>::abi_read(reader)?;
+		Ok(if status { Some(value) } else { None })
+	}
+}
modifiedcrates/evm-coder/src/abi/test.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/abi/test.rs
+++ b/crates/evm-coder/src/abi/test.rs
@@ -538,3 +538,68 @@
 	assert_eq!(p1, 0x0a);
 	assert_eq!(p2, 0x0b);
 }
+
+#[test]
+fn encode_decode_option_uint8_some() {
+	test_impl::<Option<u8>>(
+		0xdeadbeef,
+		Some(44),
+		&hex!(
+			"
+                deadbeef
+                0000000000000000000000000000000000000000000000000000000000000001
+                000000000000000000000000000000000000000000000000000000000000002c
+            "
+		),
+	);
+}
+
+#[test]
+fn encode_decode_option_uint8_none() {
+	test_impl::<Option<u8>>(
+		0xdeadbeef,
+		None,
+		&hex!(
+			"
+                deadbeef
+                0000000000000000000000000000000000000000000000000000000000000000
+                0000000000000000000000000000000000000000000000000000000000000000
+            "
+		),
+	);
+}
+
+#[test]
+fn encode_decode_option_string_some() {
+	test_impl::<Option<String>>(
+		0xdeadbeef,
+		Some("some string".to_string()),
+		&hex!(
+			"
+                deadbeef
+                0000000000000000000000000000000000000000000000000000000000000020
+                0000000000000000000000000000000000000000000000000000000000000001
+                0000000000000000000000000000000000000000000000000000000000000040
+                000000000000000000000000000000000000000000000000000000000000000b
+                736f6d6520737472696e67000000000000000000000000000000000000000000
+            "
+		),
+	);
+}
+
+#[test]
+fn encode_decode_option_string_none() {
+	test_impl::<Option<String>>(
+		0xdeadbeef,
+		None,
+		&hex!(
+			"
+                deadbeef
+                0000000000000000000000000000000000000000000000000000000000000020
+                0000000000000000000000000000000000000000000000000000000000000000
+                0000000000000000000000000000000000000000000000000000000000000040
+                0000000000000000000000000000000000000000000000000000000000000000
+            "
+		),
+	);
+}
modifiedcrates/evm-coder/src/solidity/impls.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/solidity/impls.rs
+++ b/crates/evm-coder/src/solidity/impls.rs
@@ -121,3 +121,59 @@
 impl_tuples! {A B C D E F G H}
 impl_tuples! {A B C D E F G H I}
 impl_tuples! {A B C D E F G H I J}
+
+//----- impls for Option -----
+impl<T: SolidityTypeName + 'static> SolidityTypeName for Option<T> {
+	fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {
+		write!(writer, "{}", tc.collect_struct::<Self>())
+	}
+	fn is_simple() -> bool {
+		false
+	}
+	fn solidity_default(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {
+		write!(writer, "{}(", tc.collect_struct::<Self>())?;
+		bool::solidity_default(writer, tc)?;
+		write!(writer, ", ");
+		T::solidity_default(writer, tc)?;
+		write!(writer, ")")
+	}
+}
+
+impl<T: SolidityTypeName> super::SolidityStructTy for Option<T> {
+	fn generate_solidity_interface(tc: &TypeCollector) -> String {
+		let mut solidity_name = "Option".to_string();
+		let mut generic_name = String::new();
+		T::solidity_name(&mut generic_name, tc);
+		solidity_name.push(
+			generic_name
+				.chars()
+				.next()
+				.expect("Generic name is empty")
+				.to_ascii_uppercase(),
+		);
+		solidity_name.push_str(&generic_name[1..]);
+
+		let interface = super::SolidityStruct {
+			docs: &[" Optional value"],
+			name: solidity_name.as_str(),
+			fields: (
+				super::SolidityStructField::<bool> {
+					docs: &[" Shows the status of accessibility of value"],
+					name: "status",
+					ty: ::core::marker::PhantomData,
+				},
+				super::SolidityStructField::<T> {
+					docs: &[" Actual value if `status` is true"],
+					name: "value",
+					ty: ::core::marker::PhantomData,
+				},
+			),
+		};
+
+		let mut out = String::new();
+		let _ = interface.format(&mut out, tc);
+		tc.collect(out);
+
+		solidity_name.to_string()
+	}
+}
modifiedcrates/evm-coder/src/solidity/mod.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/solidity/mod.rs
+++ b/crates/evm-coder/src/solidity/mod.rs
@@ -456,13 +456,13 @@
 		Ok(())
 	}
 }
-pub struct SolidityStruct<F> {
-	pub docs: &'static [&'static str],
+pub struct SolidityStruct<'a, F> {
+	pub docs: &'a [&'a str],
 	// pub generics:
-	pub name: &'static str,
+	pub name: &'a str,
 	pub fields: F,
 }
-impl<F> SolidityStruct<F>
+impl<F> SolidityStruct<'_, F>
 where
 	F: SolidityItems,
 {
modifiedpallets/common/src/erc.rsdiffbeforeafterboth
--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -284,6 +284,11 @@
 	fn collection_limits(&self) -> Result<Vec<eth::CollectionLimit>> {
 		let limits = &self.collection.limits;
 
+		let convert_value_from_bool = |ob: Option<bool>| match ob {
+			Some(b) => Some(b as u32),
+			None => None,
+		};
+
 		Ok(vec![
 			eth::CollectionLimit::new(
 				eth::CollectionLimitField::AccountTokenOwnership,
@@ -297,15 +302,15 @@
 				.sponsored_data_rate_limit
 				.and_then(|limit| {
 					if let SponsoringRateLimit::Blocks(blocks) = limit {
-						Some(eth::CollectionLimit::new::<u32>(
+						Some(eth::CollectionLimit::new(
 							eth::CollectionLimitField::SponsoredDataRateLimit,
-							blocks,
+							Some(blocks),
 						))
 					} else {
 						None
 					}
 				})
-				.unwrap_or(eth::CollectionLimit::new::<u32>(
+				.unwrap_or(eth::CollectionLimit::new(
 					eth::CollectionLimitField::SponsoredDataRateLimit,
 					Default::default(),
 				)),
@@ -320,15 +325,15 @@
 			),
 			eth::CollectionLimit::new(
 				eth::CollectionLimitField::OwnerCanTransfer,
-				limits.owner_can_transfer,
+				convert_value_from_bool(limits.owner_can_transfer),
 			),
 			eth::CollectionLimit::new(
 				eth::CollectionLimitField::OwnerCanDestroy,
-				limits.owner_can_destroy,
+				convert_value_from_bool(limits.owner_can_destroy),
 			),
 			eth::CollectionLimit::new(
 				eth::CollectionLimitField::TransferEnabled,
-				limits.transfers_enabled,
+				convert_value_from_bool(limits.transfers_enabled),
 			),
 		])
 	}
modifiedpallets/common/src/eth.rsdiffbeforeafterboth
--- a/pallets/common/src/eth.rs
+++ b/pallets/common/src/eth.rs
@@ -66,71 +66,6 @@
 	T::CrossAccountId::from_sub(account_id)
 }
 
-/// Ethereum representation of Optional value with uint256.
-#[derive(Debug, Default, AbiCoder)]
-pub struct OptionUint {
-	status: bool,
-	value: uint256,
-}
-
-impl From<u32> for OptionUint {
-	fn from(value: u32) -> Self {
-		Self {
-			status: true,
-			value: uint256::from(value),
-		}
-	}
-}
-
-impl From<Option<u32>> for OptionUint {
-	fn from(value: Option<u32>) -> Self {
-		match value {
-			Some(value) => Self {
-				status: true,
-				value: value.into(),
-			},
-			None => Self {
-				status: false,
-				value: Default::default(),
-			},
-		}
-	}
-}
-
-impl From<bool> for OptionUint {
-	fn from(value: bool) -> Self {
-		Self {
-			status: true,
-			value: if value {
-				uint256::from(1)
-			} else {
-				Default::default()
-			},
-		}
-	}
-}
-
-impl From<Option<bool>> for OptionUint {
-	fn from(value: Option<bool>) -> Self {
-		match value {
-			Some(value) => Self::from(value),
-			None => Self {
-				status: false,
-				value: Default::default(),
-			},
-		}
-	}
-}
-
-/// Ethereum representation of Optional value with CrossAddress.
-#[derive(Debug, Default, AbiCoder)]
-pub struct OptionCrossAddress {
-	/// Whether or not this CrossAdress is valid and has meaning.
-	pub status: bool,
-	/// The underlying CrossAddress value. If the status is false, can be set to whatever.
-	pub value: CrossAddress,
-}
-
 /// Cross account struct
 #[derive(Debug, Default, AbiCoder)]
 pub struct CrossAddress {
@@ -252,23 +187,23 @@
 #[derive(Debug, Default, AbiCoder)]
 pub struct CollectionLimit {
 	field: CollectionLimitField,
-	value: OptionUint,
+	value: Option<uint256>,
 }
 
 impl CollectionLimit {
 	/// Create [`CollectionLimit`] from field and value.
-	pub fn new<T>(field: CollectionLimitField, value: T) -> Self
-	where
-		OptionUint: From<T>,
-	{
+	pub fn new(field: CollectionLimitField, value: Option<u32>) -> Self {
 		Self {
 			field,
-			value: value.into(),
+			value: match value {
+				Some(value) => Some(value.into()),
+				None => None,
+			},
 		}
 	}
 	/// Whether the field contains a value.
 	pub fn has_value(&self) -> bool {
-		self.value.status
+		self.value.is_some()
 	}
 }
 
@@ -276,52 +211,60 @@
 	type Error = evm_coder::execution::Error;
 
 	fn try_into(self) -> Result<up_data_structs::CollectionLimits, Self::Error> {
-		let value = self.value.value.try_into().map_err(|error| {
+		let value = self
+			.value
+			.ok_or::<Self::Error>("can't convert `None` value to boolean".into())?;
+		let value = Some(value.try_into().map_err(|error| {
 			Self::Error::Revert(format!(
 				"can't convert value to u32 \"{}\" because: \"{error}\"",
-				self.value.value
+				value
 			))
-		})?;
+		})?);
 
 		let convert_value_to_bool = || match value {
-			0 => Ok(false),
-			1 => Ok(true),
-			_ => {
-				return Err(Self::Error::Revert(format!(
-					"can't convert value to boolean \"{value}\""
-				)))
-			}
+			Some(value) => match value {
+				0 => Ok(Some(false)),
+				1 => Ok(Some(true)),
+				_ => {
+					return Err(Self::Error::Revert(format!(
+						"can't convert value to boolean \"{value}\""
+					)))
+				}
+			},
+			None => Ok(None),
 		};
 
 		let mut limits = up_data_structs::CollectionLimits::default();
 		match self.field {
 			CollectionLimitField::AccountTokenOwnership => {
-				limits.account_token_ownership_limit = Some(value);
+				limits.account_token_ownership_limit = value;
 			}
 			CollectionLimitField::SponsoredDataSize => {
-				limits.sponsored_data_size = Some(value);
+				limits.sponsored_data_size = value;
 			}
 			CollectionLimitField::SponsoredDataRateLimit => {
-				limits.sponsored_data_rate_limit =
-					Some(up_data_structs::SponsoringRateLimit::Blocks(value));
+				limits.sponsored_data_rate_limit = match value {
+					Some(value) => Some(up_data_structs::SponsoringRateLimit::Blocks(value)),
+					None => None,
+				};
 			}
 			CollectionLimitField::TokenLimit => {
-				limits.token_limit = Some(value);
+				limits.token_limit = value;
 			}
 			CollectionLimitField::SponsorTransferTimeout => {
-				limits.sponsor_transfer_timeout = Some(value);
+				limits.sponsor_transfer_timeout = value;
 			}
 			CollectionLimitField::SponsorApproveTimeout => {
-				limits.sponsor_approve_timeout = Some(value);
+				limits.sponsor_approve_timeout = value;
 			}
 			CollectionLimitField::OwnerCanTransfer => {
-				limits.owner_can_transfer = Some(convert_value_to_bool()?);
+				limits.owner_can_transfer = convert_value_to_bool()?;
 			}
 			CollectionLimitField::OwnerCanDestroy => {
-				limits.owner_can_destroy = Some(convert_value_to_bool()?);
+				limits.owner_can_destroy = convert_value_to_bool()?;
 			}
 			CollectionLimitField::TransferEnabled => {
-				limits.transfers_enabled = Some(convert_value_to_bool()?);
+				limits.transfers_enabled = convert_value_to_bool()?;
 			}
 		};
 		Ok(limits)
modifiedpallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth
--- a/pallets/evm-contract-helpers/src/eth.rs
+++ b/pallets/evm-contract-helpers/src/eth.rs
@@ -175,16 +175,10 @@
 	///
 	/// @param contractAddress The contract for which a sponsor is requested.
 	/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
-	fn sponsor(&self, contract_address: address) -> Result<eth::OptionCrossAddress> {
+	fn sponsor(&self, contract_address: address) -> Result<Option<eth::CrossAddress>> {
 		Ok(match Pallet::<T>::get_sponsor(contract_address) {
-			Some(ref value) => eth::OptionCrossAddress {
-				status: true,
-				value: eth::CrossAddress::from_sub_cross_account::<T>(value),
-			},
-			None => eth::OptionCrossAddress {
-				status: false,
-				value: Default::default(),
-			},
+			Some(ref value) => Some(eth::CrossAddress::from_sub_cross_account::<T>(value)),
+			None => None,
 		})
 	}
 
modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.soldiffbeforeafterboth
--- a/pallets/evm-contract-helpers/src/stubs/ContractHelpers.sol
+++ b/pallets/evm-contract-helpers/src/stubs/ContractHelpers.sol
@@ -281,10 +281,10 @@
 	uint256 sub;
 }
 
-/// Ethereum representation of Optional value with CrossAddress.
+/// Optional value
 struct OptionCrossAddress {
-	/// Whether or not this CrossAdress is valid and has meaning.
+	/// Shows the status of accessibility of value
 	bool status;
-	/// The underlying CrossAddress value. If the status is false, can be set to whatever.
+	/// Actual value if `status` is true
 	CrossAddress value;
 }
modifiedpallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth
--- a/pallets/fungible/src/stubs/UniqueFungible.sol
+++ b/pallets/fungible/src/stubs/UniqueFungible.sol
@@ -466,12 +466,14 @@
 /// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
 struct CollectionLimit {
 	CollectionLimitField field;
-	OptionUint value;
+	OptionUint256 value;
 }
 
-/// Ethereum representation of Optional value with uint256.
-struct OptionUint {
+/// Optional value
+struct OptionUint256 {
+	/// Shows the status of accessibility of value
 	bool status;
+	/// Actual value if `status` is true
 	uint256 value;
 }
 
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -608,12 +608,14 @@
 /// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
 struct CollectionLimit {
 	CollectionLimitField field;
-	OptionUint value;
+	OptionUint256 value;
 }
 
-/// Ethereum representation of Optional value with uint256.
-struct OptionUint {
+/// Optional value
+struct OptionUint256 {
+	/// Shows the status of accessibility of value
 	bool status;
+	/// Actual value if `status` is true
 	uint256 value;
 }
 
modifiedpallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth
--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -608,12 +608,14 @@
 /// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
 struct CollectionLimit {
 	CollectionLimitField field;
-	OptionUint value;
+	OptionUint256 value;
 }
 
-/// Ethereum representation of Optional value with uint256.
-struct OptionUint {
+/// Optional value
+struct OptionUint256 {
+	/// Shows the status of accessibility of value
 	bool status;
+	/// Actual value if `status` is true
 	uint256 value;
 }
 
modifiedruntime/common/identity.rsdiffbeforeafterboth
--- a/runtime/common/identity.rs
+++ b/runtime/common/identity.rs
@@ -24,9 +24,6 @@
 	transaction_validity::{TransactionValidity, ValidTransaction, TransactionValidityError},
 };
 
-#[cfg(feature = "collator-selection")]
-use sp_runtime::transaction_validity::InvalidTransaction;
-
 #[derive(Debug, Encode, Decode, PartialEq, Eq, Clone, TypeInfo)]
 pub struct DisableIdentityCalls;
 
modifiedtests/src/eth/abi/fungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/fungible.json
+++ b/tests/src/eth/abi/fungible.json
@@ -222,7 +222,7 @@
               { "internalType": "bool", "name": "status", "type": "bool" },
               { "internalType": "uint256", "name": "value", "type": "uint256" }
             ],
-            "internalType": "struct OptionUint",
+            "internalType": "struct OptionUint256",
             "name": "value",
             "type": "tuple"
           }
@@ -508,7 +508,7 @@
               { "internalType": "bool", "name": "status", "type": "bool" },
               { "internalType": "uint256", "name": "value", "type": "uint256" }
             ],
-            "internalType": "struct OptionUint",
+            "internalType": "struct OptionUint256",
             "name": "value",
             "type": "tuple"
           }
modifiedtests/src/eth/abi/fungibleDeprecated.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/fungibleDeprecated.json
+++ b/tests/src/eth/abi/fungibleDeprecated.json
@@ -88,14 +88,5 @@
     "outputs": [],
     "stateMutability": "nonpayable",
     "type": "function"
-  },
-  {
-    "inputs": [
-      { "internalType": "address", "name": "newOwner", "type": "address" }
-    ],
-    "name": "changeCollectionOwner",
-    "outputs": [],
-    "stateMutability": "nonpayable",
-    "type": "function"
   }
 ]
modifiedtests/src/eth/abi/nonFungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/nonFungible.json
+++ b/tests/src/eth/abi/nonFungible.json
@@ -51,12 +51,6 @@
   },
   {
     "anonymous": false,
-    "inputs": [],
-    "name": "MintingFinished",
-    "type": "event"
-  },
-  {
-    "anonymous": false,
     "inputs": [
       {
         "indexed": true,
@@ -252,7 +246,7 @@
               { "internalType": "bool", "name": "status", "type": "bool" },
               { "internalType": "uint256", "name": "value", "type": "uint256" }
             ],
-            "internalType": "struct OptionUint",
+            "internalType": "struct OptionUint256",
             "name": "value",
             "type": "tuple"
           }
@@ -420,13 +414,6 @@
     "name": "description",
     "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
     "stateMutability": "view",
-    "type": "function"
-  },
-  {
-    "inputs": [],
-    "name": "finishMinting",
-    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
-    "stateMutability": "nonpayable",
     "type": "function"
   },
   {
@@ -513,13 +500,6 @@
     "name": "mintWithTokenURI",
     "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
     "stateMutability": "nonpayable",
-    "type": "function"
-  },
-  {
-    "inputs": [],
-    "name": "mintingFinished",
-    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
-    "stateMutability": "view",
     "type": "function"
   },
   {
@@ -670,7 +650,7 @@
               { "internalType": "bool", "name": "status", "type": "bool" },
               { "internalType": "uint256", "name": "value", "type": "uint256" }
             ],
-            "internalType": "struct OptionUint",
+            "internalType": "struct OptionUint256",
             "name": "value",
             "type": "tuple"
           }
modifiedtests/src/eth/abi/reFungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/reFungible.json
+++ b/tests/src/eth/abi/reFungible.json
@@ -51,12 +51,6 @@
   },
   {
     "anonymous": false,
-    "inputs": [],
-    "name": "MintingFinished",
-    "type": "event"
-  },
-  {
-    "anonymous": false,
     "inputs": [
       {
         "indexed": true,
@@ -234,7 +228,7 @@
               { "internalType": "bool", "name": "status", "type": "bool" },
               { "internalType": "uint256", "name": "value", "type": "uint256" }
             ],
-            "internalType": "struct OptionUint",
+            "internalType": "struct OptionUint256",
             "name": "value",
             "type": "tuple"
           }
@@ -402,13 +396,6 @@
     "name": "description",
     "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
     "stateMutability": "view",
-    "type": "function"
-  },
-  {
-    "inputs": [],
-    "name": "finishMinting",
-    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
-    "stateMutability": "nonpayable",
     "type": "function"
   },
   {
@@ -495,13 +482,6 @@
     "name": "mintWithTokenURI",
     "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
     "stateMutability": "nonpayable",
-    "type": "function"
-  },
-  {
-    "inputs": [],
-    "name": "mintingFinished",
-    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
-    "stateMutability": "view",
     "type": "function"
   },
   {
@@ -652,7 +632,7 @@
               { "internalType": "bool", "name": "status", "type": "bool" },
               { "internalType": "uint256", "name": "value", "type": "uint256" }
             ],
-            "internalType": "struct OptionUint",
+            "internalType": "struct OptionUint256",
             "name": "value",
             "type": "tuple"
           }
modifiedtests/src/eth/abi/reFungibleDeprecated.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/reFungibleDeprecated.json
+++ b/tests/src/eth/abi/reFungibleDeprecated.json
@@ -82,6 +82,17 @@
   },
   {
     "inputs": [
+      { "internalType": "uint256", "name": "tokenId", "type": "uint256" },
+      { "internalType": "string", "name": "key", "type": "string" },
+      { "internalType": "bytes", "name": "value", "type": "bytes" }
+    ],
+    "name": "setProperty",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "address", "name": "newOwner", "type": "address" }
     ],
     "name": "changeCollectionOwner",
modifiedtests/src/eth/abi/reFungibleToken.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/reFungibleToken.json
+++ b/tests/src/eth/abi/reFungibleToken.json
@@ -98,16 +98,6 @@
   },
   {
     "inputs": [
-      { "internalType": "address", "name": "from", "type": "address" },
-      { "internalType": "uint256", "name": "amount", "type": "uint256" }
-    ],
-    "name": "burnFrom",
-    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
-    "stateMutability": "nonpayable",
-    "type": "function"
-  },
-  {
-    "inputs": [
       {
         "components": [
           { "internalType": "address", "name": "eth", "type": "address" },
addedtests/src/eth/abi/reFungibleTokenDeprecated.jsondiffbeforeafterboth
--- /dev/null
+++ b/tests/src/eth/abi/reFungibleTokenDeprecated.json
@@ -0,0 +1,12 @@
+[
+  {
+    "inputs": [
+      { "internalType": "address", "name": "from", "type": "address" },
+      { "internalType": "uint256", "name": "amount", "type": "uint256" }
+    ],
+    "name": "burnFrom",
+    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  }
+]
modifiedtests/src/eth/api/ContractHelpers.soldiffbeforeafterboth
--- a/tests/src/eth/api/ContractHelpers.sol
+++ b/tests/src/eth/api/ContractHelpers.sol
@@ -181,11 +181,11 @@
 	Generous
 }
 
-/// Ethereum representation of Optional value with CrossAddress.
+/// Optional value
 struct OptionCrossAddress {
-	/// Whether or not this CrossAdress is valid and has meaning.
+	/// Shows the status of accessibility of value
 	bool status;
-	/// The underlying CrossAddress value. If the status is false, can be set to whatever.
+	/// Actual value if `status` is true
 	CrossAddress value;
 }
 
modifiedtests/src/eth/api/UniqueFungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -308,12 +308,14 @@
 /// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
 struct CollectionLimit {
 	CollectionLimitField field;
-	OptionUint value;
+	OptionUint256 value;
 }
 
-/// Ethereum representation of Optional value with uint256.
-struct OptionUint {
+/// Optional value
+struct OptionUint256 {
+	/// Shows the status of accessibility of value
 	bool status;
+	/// Actual value if `status` is true
 	uint256 value;
 }
 
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -408,12 +408,14 @@
 /// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
 struct CollectionLimit {
 	CollectionLimitField field;
-	OptionUint value;
+	OptionUint256 value;
 }
 
-/// Ethereum representation of Optional value with uint256.
-struct OptionUint {
+/// Optional value
+struct OptionUint256 {
+	/// Shows the status of accessibility of value
 	bool status;
+	/// Actual value if `status` is true
 	uint256 value;
 }
 
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -408,12 +408,14 @@
 /// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
 struct CollectionLimit {
 	CollectionLimitField field;
-	OptionUint value;
+	OptionUint256 value;
 }
 
-/// Ethereum representation of Optional value with uint256.
-struct OptionUint {
+/// Optional value
+struct OptionUint256 {
+	/// Shows the status of accessibility of value
 	bool status;
+	/// Actual value if `status` is true
 	uint256 value;
 }
 
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
after · tests/src/eth/reFungible.test.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {Pallets, requirePalletsOrSkip} from '../util';18import {expect, itEth, usingEthPlaygrounds} from './util';19import {IKeyringPair} from '@polkadot/types/types';20import {ITokenPropertyPermission} from '../util/playgrounds/types';2122describe('Refungible: Plain calls', () => {23  let donor: IKeyringPair;24  let minter: IKeyringPair;25  let bob: IKeyringPair;26  let charlie: IKeyringPair;2728  before(async function() {29    await usingEthPlaygrounds(async (helper, privateKey) => {30      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);3132      donor = await privateKey({filename: __filename});33      [minter, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);34    });35  });3637  [38    'substrate' as const,39    'ethereum' as const,40  ].map(testCase => {41    itEth(`Can perform mintCross() for ${testCase} address`, async ({helper}) => {42      const collectionAdmin = await helper.eth.createAccountWithBalance(donor);4344      const receiverEth = helper.eth.createAccount();45      const receiverCrossEth = helper.ethCrossAccount.fromAddress(receiverEth);46      const receiverSub = bob;47      const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(receiverSub);4849      const properties = Array(5).fill(0).map((_, i) => { return {key: `key_${i}`, value: Buffer.from(`value_${i}`)}; });50      const permissions: ITokenPropertyPermission[] = properties.map(p => { return {key: p.key, permission: {51        tokenOwner: false,52        collectionAdmin: true,53        mutable: false}};54      });555657      const collection = await helper.rft.mintCollection(minter, {58        tokenPrefix: 'ethp',59        tokenPropertyPermissions: permissions,60      });61      await collection.addAdmin(minter, {Ethereum: collectionAdmin});6263      const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);64      const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', collectionAdmin, true);65      let expectedTokenId = await contract.methods.nextTokenId().call();66      let result = await contract.methods.mintCross(testCase === 'ethereum' ? receiverCrossEth : receiverCrossSub, []).send();67      let tokenId = result.events.Transfer.returnValues.tokenId;68      expect(tokenId).to.be.equal(expectedTokenId);6970      let event = result.events.Transfer;71      expect(event.address).to.be.equal(collectionAddress);72      expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');73      expect(event.returnValues.to).to.be.equal(testCase === 'ethereum' ? receiverEth : helper.address.substrateToEth(bob.address));74      expect(await contract.methods.properties(tokenId, []).call()).to.be.like([]);7576      expectedTokenId = await contract.methods.nextTokenId().call();77      result = await contract.methods.mintCross(testCase === 'ethereum' ? receiverCrossEth : receiverCrossSub, properties).send();78      event = result.events.Transfer;79      expect(event.address).to.be.equal(collectionAddress);80      expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');81      expect(event.returnValues.to).to.be.equal(testCase === 'ethereum' ? receiverEth : helper.address.substrateToEth(bob.address));82      expect(await contract.methods.properties(tokenId, []).call()).to.be.like([]);8384      tokenId = result.events.Transfer.returnValues.tokenId;8586      expect(tokenId).to.be.equal(expectedTokenId);8788      expect(await contract.methods.properties(tokenId, []).call()).to.be.like(properties89        .map(p => { return helper.ethProperty.property(p.key, p.value.toString()); }));9091      expect(await helper.nft.getTokenOwner(collection.collectionId, tokenId))92        .to.deep.eq(testCase === 'ethereum' ? {Ethereum: receiverEth.toLowerCase()} : {Substrate: receiverSub.address});93    });94  });9596  itEth.skip('Can perform mintBulk()', async ({helper}) => {97    const owner = await helper.eth.createAccountWithBalance(donor);98    const receiver = helper.eth.createAccount();99    const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, 'MintBulky', '6', '6', '');100    const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', owner);101102    {103      const nextTokenId = await contract.methods.nextTokenId().call();104      expect(nextTokenId).to.be.equal('1');105      const result = await contract.methods.mintBulkWithTokenURI(106        receiver,107        [108          [nextTokenId, 'Test URI 0'],109          [+nextTokenId + 1, 'Test URI 1'],110          [+nextTokenId + 2, 'Test URI 2'],111        ],112      ).send();113114      const events = result.events.Transfer;115      for (let i = 0; i < 2; i++) {116        const event = events[i];117        expect(event.address).to.equal(collectionAddress);118        expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');119        expect(event.returnValues.to).to.equal(receiver);120        expect(event.returnValues.tokenId).to.equal(String(+nextTokenId + i));121      }122123      expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI 0');124      expect(await contract.methods.tokenURI(+nextTokenId + 1).call()).to.be.equal('Test URI 1');125      expect(await contract.methods.tokenURI(+nextTokenId + 2).call()).to.be.equal('Test URI 2');126    }127  });128129  itEth('Can perform setApprovalForAll()', async ({helper}) => {130    const owner = await helper.eth.createAccountWithBalance(donor);131    const operator = helper.eth.createAccount();132133    const collection = await helper.rft.mintCollection(minter, {});134135    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);136    const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', owner);137138    const approvedBefore = await contract.methods.isApprovedForAll(owner, operator).call();139    expect(approvedBefore).to.be.equal(false);140141    {142      const result = await contract.methods.setApprovalForAll(operator, true).send({from: owner});143144      expect(result.events.ApprovalForAll).to.be.like({145        address: collectionAddress,146        event: 'ApprovalForAll',147        returnValues: {148          owner,149          operator,150          approved: true,151        },152      });153154      const approvedAfter = await contract.methods.isApprovedForAll(owner, operator).call();155      expect(approvedAfter).to.be.equal(true);156    }157158    {159      const result = await contract.methods.setApprovalForAll(operator, false).send({from: owner});160161      expect(result.events.ApprovalForAll).to.be.like({162        address: collectionAddress,163        event: 'ApprovalForAll',164        returnValues: {165          owner,166          operator,167          approved: false,168        },169      });170171      const approvedAfter = await contract.methods.isApprovedForAll(owner, operator).call();172      expect(approvedAfter).to.be.equal(false);173    }174  });175176  itEth('Can perform burn with ApprovalForAll', async ({helper}) => {177    const collection = await helper.rft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});178179    const owner = await helper.eth.createAccountWithBalance(donor);180    const operator = await helper.eth.createAccountWithBalance(donor, 100n);181182    const token = await collection.mintToken(minter, 100n, {Ethereum: owner});183184    const address = helper.ethAddress.fromCollectionId(collection.collectionId);185    const contract = await helper.ethNativeContract.collection(address, 'rft');186187    {188      await contract.methods.setApprovalForAll(operator, true).send({from: owner});189      const ownerCross = helper.ethCrossAccount.fromAddress(owner);190      const result = await contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: operator});191      const events = result.events.Transfer;192193      expect(events).to.be.like({194        address,195        event: 'Transfer',196        returnValues: {197          from: owner,198          to: '0x0000000000000000000000000000000000000000',199          tokenId: token.tokenId.toString(),200        },201      });202    }203  });204205  itEth('Can perform burn with approve and approvalForAll', async ({helper}) => {206    const collection = await helper.rft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});207208    const owner = await helper.eth.createAccountWithBalance(donor);209    const operator = await helper.eth.createAccountWithBalance(donor, 100n);210211    const token = await collection.mintToken(minter, 100n, {Ethereum: owner});212213    const address = helper.ethAddress.fromCollectionId(collection.collectionId);214    const contract = await helper.ethNativeContract.collection(address, 'rft');215216    const rftToken = await helper.ethNativeContract.rftTokenById(token.collectionId, token.tokenId, owner, true);217218    {219      await rftToken.methods.approve(operator, 15n).send({from: owner});220      await contract.methods.setApprovalForAll(operator, true).send({from: owner});221      await rftToken.methods.burnFrom(owner, 10n).send({from: operator});222      const allowance = await rftToken.methods.allowance(owner, operator).call();223      expect(allowance).to.be.equal('5');224    }225  });226227  itEth('Can perform transfer with ApprovalForAll', async ({helper}) => {228    const collection = await helper.rft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});229230    const owner = await helper.eth.createAccountWithBalance(donor);231    const operator = await helper.eth.createAccountWithBalance(donor);232    const receiver = charlie;233234    const token = await collection.mintToken(minter, 100n, {Ethereum: owner});235236    const address = helper.ethAddress.fromCollectionId(collection.collectionId);237    const contract = await helper.ethNativeContract.collection(address, 'rft');238239    {240      await contract.methods.setApprovalForAll(operator, true).send({from: owner});241      const ownerCross = helper.ethCrossAccount.fromAddress(owner);242      const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);243      const result = await contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: operator});244      const event = result.events.Transfer;245      expect(event).to.be.like({246        address: helper.ethAddress.fromCollectionId(collection.collectionId),247        event: 'Transfer',248        returnValues: {249          from: owner,250          to: helper.address.substrateToEth(receiver.address),251          tokenId: token.tokenId.toString(),252        },253      });254    }255256    expect(await token.getTop10Owners()).to.be.like([{Substrate: receiver.address}]);257  });258259  itEth('Can perform burn()', async ({helper}) => {260    const caller = await helper.eth.createAccountWithBalance(donor);261    const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Burny', '6', '6');262    const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);263264    const result = await contract.methods.mint(caller).send();265    const tokenId = result.events.Transfer.returnValues.tokenId;266    {267      const result = await contract.methods.burn(tokenId).send();268      const event = result.events.Transfer;269      expect(event.address).to.equal(collectionAddress);270      expect(event.returnValues.from).to.equal(caller);271      expect(event.returnValues.to).to.equal('0x0000000000000000000000000000000000000000');272      expect(event.returnValues.tokenId).to.equal(tokenId.toString());273    }274  });275276  itEth('Can perform transferFrom()', async ({helper}) => {277    const caller = await helper.eth.createAccountWithBalance(donor);278    const receiver = helper.eth.createAccount();279    const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'TransferFromy', '6', '6');280    const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);281282    const result = await contract.methods.mint(caller).send();283    const tokenId = result.events.Transfer.returnValues.tokenId;284285    const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);286287    const tokenContract = await helper.ethNativeContract.rftToken(tokenAddress, caller);288    await tokenContract.methods.repartition(15).send();289290    {291      const tokenEvents: any = [];292      tokenContract.events.allEvents((_: any, event: any) => {293        tokenEvents.push(event);294      });295      const result = await contract.methods.transferFrom(caller, receiver, tokenId).send();296      if (tokenEvents.length == 0) await helper.wait.newBlocks(1);297298      let event = result.events.Transfer;299      expect(event.address).to.equal(collectionAddress);300      expect(event.returnValues.from).to.equal(caller);301      expect(event.returnValues.to).to.equal(receiver);302      expect(event.returnValues.tokenId).to.equal(tokenId.toString());303304      event = tokenEvents[0];305      expect(event.address).to.equal(tokenAddress);306      expect(event.returnValues.from).to.equal(caller);307      expect(event.returnValues.to).to.equal(receiver);308      expect(event.returnValues.value).to.equal('15');309    }310311    {312      const balance = await contract.methods.balanceOf(receiver).call();313      expect(+balance).to.equal(1);314    }315316    {317      const balance = await contract.methods.balanceOf(caller).call();318      expect(+balance).to.equal(0);319    }320  });321322  // Soft-deprecated323  itEth('Can perform burnFrom()', async ({helper}) => {324    const collection = await helper.rft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});325326    const owner = await helper.eth.createAccountWithBalance(donor, 100n);327    const spender = await helper.eth.createAccountWithBalance(donor, 100n);328329    const token = await collection.mintToken(minter, 100n, {Ethereum: owner});330331    const address = helper.ethAddress.fromCollectionId(collection.collectionId);332    const contract = await helper.ethNativeContract.collection(address, 'rft', spender, true);333334    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, token.tokenId);335    const tokenContract = await helper.ethNativeContract.rftToken(tokenAddress, owner);336    await tokenContract.methods.repartition(15).send();337    await tokenContract.methods.approve(spender, 15).send();338339    {340      const result = await contract.methods.burnFrom(owner, token.tokenId).send();341      const event = result.events.Transfer;342      expect(event).to.be.like({343        address: helper.ethAddress.fromCollectionId(collection.collectionId),344        event: 'Transfer',345        returnValues: {346          from: owner,347          to: '0x0000000000000000000000000000000000000000',348          tokenId: token.tokenId.toString(),349        },350      });351    }352353    expect(await collection.getTokenBalance(token.tokenId, {Ethereum: owner})).to.be.eq(0n);354  });355356  itEth('Can perform burnFromCross()', async ({helper}) => {357    const collection = await helper.rft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});358359    const owner = bob;360    const spender = await helper.eth.createAccountWithBalance(donor, 100n);361362    const token = await collection.mintToken(minter, 100n, {Substrate: owner.address});363364    const address = helper.ethAddress.fromCollectionId(collection.collectionId);365    const contract = await helper.ethNativeContract.collection(address, 'rft');366367    await token.repartition(owner, 15n);368    await token.approve(owner, {Ethereum: spender}, 15n);369370    {371      const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);372      const result = await contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender});373      const event = result.events.Transfer;374      expect(event).to.be.like({375        address: helper.ethAddress.fromCollectionId(collection.collectionId),376        event: 'Transfer',377        returnValues: {378          from: helper.address.substrateToEth(owner.address),379          to: '0x0000000000000000000000000000000000000000',380          tokenId: token.tokenId.toString(),381        },382      });383    }384385    expect(await collection.getTokenBalance(token.tokenId, {Substrate: owner.address})).to.be.eq(0n);386  });387388  itEth('Can perform transferFromCross()', async ({helper}) => {389    const collection = await helper.rft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});390391    const owner = bob;392    const spender = await helper.eth.createAccountWithBalance(donor, 100n);393    const receiver = charlie;394395    const token = await collection.mintToken(minter, 100n, {Substrate: owner.address});396397    const address = helper.ethAddress.fromCollectionId(collection.collectionId);398    const contract = await helper.ethNativeContract.collection(address, 'rft');399400    await token.repartition(owner, 15n);401    await token.approve(owner, {Ethereum: spender}, 15n);402403    {404      const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);405      const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);406      const result = await contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender});407      const event = result.events.Transfer;408      expect(event).to.be.like({409        address: helper.ethAddress.fromCollectionId(collection.collectionId),410        event: 'Transfer',411        returnValues: {412          from: helper.address.substrateToEth(owner.address),413          to: helper.address.substrateToEth(receiver.address),414          tokenId: token.tokenId.toString(),415        },416      });417    }418419    expect(await token.getTop10Owners()).to.be.like([{Substrate: receiver.address}]);420  });421422  itEth('Can perform transfer()', async ({helper}) => {423    const caller = await helper.eth.createAccountWithBalance(donor);424    const receiver = helper.eth.createAccount();425    const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Transferry', '6', '6');426    const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);427428    const result = await contract.methods.mint(caller).send();429    const tokenId = result.events.Transfer.returnValues.tokenId;430431    {432      const result = await contract.methods.transfer(receiver, tokenId).send();433434      const event = result.events.Transfer;435      expect(event.address).to.equal(collectionAddress);436      expect(event.returnValues.from).to.equal(caller);437      expect(event.returnValues.to).to.equal(receiver);438      expect(event.returnValues.tokenId).to.equal(tokenId.toString());439    }440441    {442      const balance = await contract.methods.balanceOf(caller).call();443      expect(+balance).to.equal(0);444    }445446    {447      const balance = await contract.methods.balanceOf(receiver).call();448      expect(+balance).to.equal(1);449    }450  });451452  itEth('Can perform transferCross()', async ({helper}) => {453    const sender = await helper.eth.createAccountWithBalance(donor);454    const receiverEth = await helper.eth.createAccountWithBalance(donor);455    const receiverCrossEth = helper.ethCrossAccount.fromAddress(receiverEth);456    const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(minter);457458    const collection = await helper.rft.mintCollection(minter, {});459    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);460    const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'rft', sender);461462    const token = await collection.mintToken(minter, 50n, {Ethereum: sender});463464    {465      // Can transferCross to ethereum address:466      const result = await collectionEvm.methods.transferCross(receiverCrossEth, token.tokenId).send({from: sender});467      // Check events:468      const event = result.events.Transfer;469      expect(event.address).to.equal(collectionAddress);470      expect(event.returnValues.from).to.equal(sender);471      expect(event.returnValues.to).to.equal(receiverEth);472      expect(event.returnValues.tokenId).to.equal(token.tokenId.toString());473      // Sender's balance decreased:474      const senderBalance = await collectionEvm.methods.balanceOf(sender).call();475      expect(+senderBalance).to.equal(0);476      expect(await token.getBalance({Ethereum: sender})).to.eq(0n);477      // Receiver's balance increased:478      const receiverBalance = await collectionEvm.methods.balanceOf(receiverEth).call();479      expect(+receiverBalance).to.equal(1);480      expect(await token.getBalance({Ethereum: receiverEth})).to.eq(50n);481    }482483    {484      // Can transferCross to substrate address:485      const substrateResult = await collectionEvm.methods.transferCross(receiverCrossSub, token.tokenId).send({from: receiverEth});486      // Check events:487      const event = substrateResult.events.Transfer;488      expect(event.address).to.be.equal(collectionAddress);489      expect(event.returnValues.from).to.be.equal(receiverEth);490      expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(minter.address));491      expect(event.returnValues.tokenId).to.be.equal(`${token.tokenId}`);492      // Sender's balance decreased:493      const senderBalance = await collectionEvm.methods.balanceOf(receiverEth).call();494      expect(+senderBalance).to.equal(0);495      expect(await token.getBalance({Ethereum: receiverEth})).to.eq(0n);496      // Receiver's balance increased:497      const receiverBalance = await helper.nft.getTokensByAddress(collection.collectionId, {Substrate: minter.address});498      expect(receiverBalance).to.contain(token.tokenId);499      expect(await token.getBalance({Substrate: minter.address})).to.eq(50n);500    }501  });502503  ['transfer', 'transferCross'].map(testCase => itEth(`Cannot ${testCase} non-owned token`, async ({helper}) => {504    const sender = await helper.eth.createAccountWithBalance(donor);505    const tokenOwner = await helper.eth.createAccountWithBalance(donor);506    const receiverSub = minter;507    const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(minter);508509    const collection = await helper.rft.mintCollection(minter, {});510    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);511    const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'rft', sender);512513    await collection.mintToken(minter, 50n, {Ethereum: sender});514    const nonSendersToken = await collection.mintToken(minter, 50n, {Ethereum: tokenOwner});515516    // Cannot transferCross someone else's token:517    const receiver = testCase === 'transfer' ? helper.address.substrateToEth(receiverSub.address) : receiverCrossSub;518    await expect(collectionEvm.methods[testCase](receiver, nonSendersToken.tokenId).send({from: sender})).to.be.rejected;519    // Cannot transfer token if it does not exist:520    await expect(collectionEvm.methods[testCase](receiver, 999999).send({from: sender})).to.be.rejected;521  }));522523  itEth('transfer event on transfer from partial ownership to full ownership', async ({helper}) => {524    const caller = await helper.eth.createAccountWithBalance(donor);525    const receiver = helper.eth.createAccount();526    const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Transferry-Partial-to-Full', '6', '6');527    const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);528529    const result = await contract.methods.mint(caller).send();530    const tokenId = result.events.Transfer.returnValues.tokenId;531532    const tokenContract = await helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);533534    await tokenContract.methods.repartition(2).send();535    await tokenContract.methods.transfer(receiver, 1).send();536537    const events: any = [];538    contract.events.allEvents((_: any, event: any) => {539      events.push(event);540    });541542    await tokenContract.methods.transfer(receiver, 1).send();543    if (events.length == 0) await helper.wait.newBlocks(1);544    const event = events[0];545546    expect(event.address).to.equal(collectionAddress);547    expect(event.returnValues.from).to.equal('0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF');548    expect(event.returnValues.to).to.equal(receiver);549    expect(event.returnValues.tokenId).to.equal(tokenId.toString());550  });551552  itEth('transfer event on transfer from full ownership to partial ownership', async ({helper}) => {553    const caller = await helper.eth.createAccountWithBalance(donor);554    const receiver = helper.eth.createAccount();555    const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Transferry-Full-to-Partial', '6', '6');556    const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);557558    const result = await contract.methods.mint(caller).send();559    const tokenId = result.events.Transfer.returnValues.tokenId;560561    const tokenContract = await helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);562563    await tokenContract.methods.repartition(2).send();564565    const events: any = [];566    contract.events.allEvents((_: any, event: any) => {567      events.push(event);568    });569570    await tokenContract.methods.transfer(receiver, 1).send();571    if (events.length == 0) await helper.wait.newBlocks(1);572    const event = events[0];573574    expect(event.address).to.equal(collectionAddress);575    expect(event.returnValues.from).to.equal(caller);576    expect(event.returnValues.to).to.equal('0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF');577    expect(event.returnValues.tokenId).to.equal(tokenId.toString());578  });579});580581describe('RFT: Fees', () => {582  let donor: IKeyringPair;583584  before(async function() {585    await usingEthPlaygrounds(async (helper, privateKey) => {586      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);587588      donor = await privateKey({filename: __filename});589    });590  });591592  itEth('transferFrom() call fee is less than 0.2UNQ', async ({helper}) => {593    const caller = await helper.eth.createAccountWithBalance(donor);594    const receiver = helper.eth.createAccount();595    const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Feeful-Transfer-From', '6', '6');596    const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);597598    const result = await contract.methods.mint(caller).send();599    const tokenId = result.events.Transfer.returnValues.tokenId;600601    const cost = await helper.eth.recordCallFee(caller, () => contract.methods.transferFrom(caller, receiver, tokenId).send());602    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));603    expect(cost > 0n);604  });605606  itEth('transfer() call fee is less than 0.2UNQ', async ({helper}) => {607    const caller = await helper.eth.createAccountWithBalance(donor);608    const receiver = helper.eth.createAccount();609    const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Feeful-Transfer', '6', '6');610    const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);611612    const result = await contract.methods.mint(caller).send();613    const tokenId = result.events.Transfer.returnValues.tokenId;614615    const cost = await helper.eth.recordCallFee(caller, () => contract.methods.transfer(receiver, tokenId).send());616    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));617    expect(cost > 0n);618  });619});620621describe('Common metadata', () => {622  let donor: IKeyringPair;623  let alice: IKeyringPair;624625  before(async function() {626    await usingEthPlaygrounds(async (helper, privateKey) => {627      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);628629      donor = await privateKey({filename: __filename});630      [alice] = await helper.arrange.createAccounts([20n], donor);631    });632  });633634  itEth('Returns collection name', async ({helper}) => {635    const caller = helper.eth.createAccount();636    const tokenPropertyPermissions = [{637      key: 'URI',638      permission: {639        mutable: true,640        collectionAdmin: true,641        tokenOwner: false,642      },643    }];644    const collection = await helper.rft.mintCollection(645      alice,646      {647        name: 'Leviathan',648        tokenPrefix: '11',649        properties: [{key: 'ERC721Metadata', value: '1'}],650        tokenPropertyPermissions,651      },652    );653654    const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'rft', caller);655    const name = await contract.methods.name().call();656    expect(name).to.equal('Leviathan');657  });658659  itEth('Returns symbol name', async ({helper}) => {660    const caller = await helper.eth.createAccountWithBalance(donor);661    const tokenPropertyPermissions = [{662      key: 'URI',663      permission: {664        mutable: true,665        collectionAdmin: true,666        tokenOwner: false,667      },668    }];669    const {collectionId} = await helper.rft.mintCollection(670      alice,671      {672        name: 'Leviathan',673        tokenPrefix: '12',674        properties: [{key: 'ERC721Metadata', value: '1'}],675        tokenPropertyPermissions,676      },677    );678679    const contract = await helper.ethNativeContract.collectionById(collectionId, 'rft', caller);680    const symbol = await contract.methods.symbol().call();681    expect(symbol).to.equal('12');682  });683});684685describe('Negative tests', () => {686  let donor: IKeyringPair;687  let minter: IKeyringPair;688  let alice: IKeyringPair;689690  before(async function() {691    await usingEthPlaygrounds(async (helper, privateKey) => {692      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);693694      donor = await privateKey({filename: __filename});695      [minter, alice] = await helper.arrange.createAccounts([100n, 100n], donor);696    });697  });698699  itEth('[negative] Cant perform burn without approval', async ({helper}) => {700    const collection = await helper.rft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});701702    const owner = await helper.eth.createAccountWithBalance(donor, 100n);703    const spender = await helper.eth.createAccountWithBalance(donor, 100n);704705    const token = await collection.mintToken(minter, 100n, {Ethereum: owner});706707    const address = helper.ethAddress.fromCollectionId(collection.collectionId);708    const contract = await helper.ethNativeContract.collection(address, 'rft');709710    const ownerCross = helper.ethCrossAccount.fromAddress(owner);711712    await expect(contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender})).to.be.rejected;713714    await contract.methods.setApprovalForAll(spender, true).send({from: owner});715    await contract.methods.setApprovalForAll(spender, false).send({from: owner});716717    await expect(contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender})).to.be.rejected;718  });719720  itEth('[negative] Cant perform transfer without approval', async ({helper}) => {721    const collection = await helper.rft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});722    const owner = await helper.eth.createAccountWithBalance(donor, 100n);723    const receiver = alice;724725    const spender = await helper.eth.createAccountWithBalance(donor, 100n);726727    const token = await collection.mintToken(minter, 100n, {Ethereum: owner});728729    const address = helper.ethAddress.fromCollectionId(collection.collectionId);730    const contract = await helper.ethNativeContract.collection(address, 'rft');731732    const ownerCross = helper.ethCrossAccount.fromAddress(owner);733    const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);734735    await expect(contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender})).to.be.rejected;736737    await contract.methods.setApprovalForAll(spender, true).send({from: owner});738    await contract.methods.setApprovalForAll(spender, false).send({from: owner});739740    await expect(contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender})).to.be.rejected;741  });742});
modifiedtests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungibleToken.test.ts
+++ b/tests/src/eth/reFungibleToken.test.ts
@@ -413,7 +413,7 @@
     const result = await contract.methods.mint(caller).send();
     const tokenId = result.events.Transfer.returnValues.tokenId;
     const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);
-    const tokenContract = await helper.ethNativeContract.rftToken(tokenAddress, caller);
+    const tokenContract = await helper.ethNativeContract.rftToken(tokenAddress, caller, true);
 
     await tokenContract.methods.repartition(2).send();
     await tokenContract.methods.transfer(receiver, 1).send();
modifiedtests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth
--- a/tests/src/eth/util/playgrounds/unique.dev.ts
+++ b/tests/src/eth/util/playgrounds/unique.dev.ts
@@ -29,6 +29,7 @@
 import refungibleAbi from '../../abi/reFungible.json';
 import refungibleDeprecatedAbi from '../../abi/reFungibleDeprecated.json';
 import refungibleTokenAbi from '../../abi/reFungibleToken.json';
+import refungibleTokenDeprecatedAbi from '../../abi/reFungibleTokenDeprecated.json';
 import contractHelpersAbi from '../../abi/contractHelpers.json';
 import {ICrossAccountId, TEthereumAccount} from '../../../util/playgrounds/types';
 import {TCollectionMode} from '../../../util/playgrounds/types';
@@ -187,17 +188,18 @@
     return this.collection(this.helper.ethAddress.fromCollectionId(collectionId), mode, caller, mergeDeprecated);
   }
 
-  async rftToken(address: string, caller?: string) {
+  async rftToken(address: string, caller?: string, mergeDeprecated = false) {
     const web3 = this.helper.getWeb3();
-    return unlimitedMoneyHack(new web3.eth.Contract(refungibleTokenAbi as any, address, {
+    const abi = mergeDeprecated ? [...refungibleTokenAbi, ...refungibleTokenDeprecatedAbi] : refungibleTokenAbi;
+    return unlimitedMoneyHack(new web3.eth.Contract(abi as any, address, {
       gas: this.helper.eth.DEFAULT_GAS,
       gasPrice: await this.getGasPrice(),
       ...(caller ? {from: caller} : {}),
     }));
   }
 
-  rftTokenById(collectionId: number, tokenId: number, caller?: string) {
-    return this.rftToken(this.helper.ethAddress.fromTokenId(collectionId, tokenId), caller);
+  rftTokenById(collectionId: number, tokenId: number, caller?: string, mergeDeprecated = false) {
+    return this.rftToken(this.helper.ethAddress.fromTokenId(collectionId, tokenId), caller, mergeDeprecated);
   }
 }