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

difftreelog

misk: Documentation, test fixes, refactor

Trubnikov Sergey2022-10-27parent: #6afd9fe.patch.diff
in: master

12 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1096,26 +1096,6 @@
 checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3"
 
 [[package]]
-name = "const_format"
-version = "0.2.30"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7309d9b4d3d2c0641e018d449232f2e28f1b22933c137f157d3dbc14228b8c0e"
-dependencies = [
- "const_format_proc_macros",
-]
-
-[[package]]
-name = "const_format_proc_macros"
-version = "0.2.29"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d897f47bf7270cf70d370f8f98c1abb6d2d4cf60a6845d30e05bfb90c6568650"
-dependencies = [
- "proc-macro2",
- "quote",
- "unicode-xid",
-]
-
-[[package]]
 name = "constant_time_eq"
 version = "0.1.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2373,7 +2353,6 @@
 version = "0.1.3"
 dependencies = [
  "concat-idents",
- "const_format",
  "ethereum",
  "evm-coder-procedural",
  "evm-core 0.35.0 (git+https://github.com/uniquenetwork/evm?branch=unique-polkadot-v0.9.30)",
modifiedcrates/evm-coder/Cargo.tomldiffbeforeafterboth
--- a/crates/evm-coder/Cargo.toml
+++ b/crates/evm-coder/Cargo.toml
@@ -5,7 +5,6 @@
 edition = "2021"
 
 [dependencies]
-const_format = { version = "0.2.26", default-features = false }
 sha3-const = { version = "0.1.1", default-features = false }
 # Ethereum uses keccak (=sha3) for selectors
 # sha3 = "0.10.1"
modifiedcrates/evm-coder/procedural/src/solidity_interface.rsdiffbeforeafterboth
--- a/crates/evm-coder/procedural/src/solidity_interface.rs
+++ b/crates/evm-coder/procedural/src/solidity_interface.rs
@@ -20,7 +20,7 @@
 // about Procedural Macros in Rust book:
 // https://doc.rust-lang.org/reference/procedural-macros.html
 
-use proc_macro2::{TokenStream, token_stream};
+use proc_macro2::TokenStream;
 use quote::{quote, ToTokens, format_ident};
 use inflector::cases;
 use std::fmt::Write;
modifiedcrates/evm-coder/src/custom_signature.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/custom_signature.rs
+++ b/crates/evm-coder/src/custom_signature.rs
@@ -1,23 +1,140 @@
+//! # A module for custom signature support.
+//!
+//! ## Overview
+//! This module allows you to create arbitrary signatures for types and functions in compile time.
+//!
+//! ### Type signatures
+//! To create the desired type signature, you need to create your own trait with the `SIGNATURE` constant.
+//! Then in the implementation, for the required type, use the macro [`make_signature`]
+//! #### Example
+//! ```
+//! use std::str::from_utf8;
+//! use evm_coder::make_signature;
+//! use evm_coder::custom_signature::{
+//! 	SignatureUnit,
+//! 	SIGNATURE_SIZE_LIMIT
+//! };
+//!
+//! // Create trait for our signature
+//! trait SoliditySignature {
+//!		const SIGNATURE: SignatureUnit;
+//!
+//!		fn name() -> &'static str {
+//!			from_utf8(&Self::SIGNATURE.data[..Self::SIGNATURE.len]).expect("bad utf-8")
+//!		}
+//!	}
+//!
+//! // Make signatures for some types
+//!	impl SoliditySignature for u8 {
+//!		make_signature!(new fixed("uint8"));
+//!	}
+//!	impl SoliditySignature for u32 {
+//!		make_signature!(new fixed("uint32"));
+//!	}
+//!	impl<T: SoliditySignature> SoliditySignature for Vec<T> {
+//!		make_signature!(new nameof(T) fixed("[]"));
+//!	}
+//!	impl<A: SoliditySignature, B: SoliditySignature> SoliditySignature for (A, B) {
+//!		make_signature!(new fixed("(") nameof(A) fixed(",") nameof(B) fixed(")"));
+//!	}
+//!	impl<A: SoliditySignature> SoliditySignature for (A,) {
+//!		make_signature!(new fixed("(") nameof(A) fixed(",") shift_left(1) fixed(")"));
+//!	}
+//!
+//! assert_eq!(u8::name(), "uint8");
+//! assert_eq!(<Vec<u8>>::name(), "uint8[]");
+//! assert_eq!(<(u32, u8)>::name(), "(uint32,uint8)");
+//! ```
+//!
+//! ### Function signatures
+//! To create a function signature, the macro [`make_signature`] is also used, which accepts
+//! settings for the function format [`SignaturePreferences`] and function parameters [`SignatureUnit`]
+//! #### Example
+//! ```
+//! use core::str::from_utf8;
+//! use evm_coder::{
+//!		make_signature,
+//!		custom_signature::{
+//!			SIGNATURE_SIZE_LIMIT, SignatureUnit, SignaturePreferences, FunctionSignature,
+//!		},
+//!	};
+//! // Trait for our signature
+//! trait SoliditySignature {
+//!		const SIGNATURE: SignatureUnit;
+//!
+//!		fn name() -> &'static str {
+//!			from_utf8(&Self::SIGNATURE.data[..Self::SIGNATURE.len]).expect("bad utf-8")
+//!		}
+//!	}
+//!
+//! // Make signatures for some types
+//!	impl SoliditySignature for u8 {
+//!		make_signature!(new fixed("uint8"));
+//!	}
+//!	impl<T: SoliditySignature> SoliditySignature for Vec<T> {
+//!		make_signature!(new nameof(T) fixed("[]"));
+//!	}
+//!
+//! // Function signature settings
+//! const SIGNATURE_PREFERENCES: SignaturePreferences = SignaturePreferences {
+//!		open_name: Some(SignatureUnit::new("some_funk")),
+//!		open_delimiter: Some(SignatureUnit::new("(")),
+//!		param_delimiter: Some(SignatureUnit::new(",")),
+//!		close_delimiter: Some(SignatureUnit::new(")")),
+//!		close_name: None,
+//!	};
+//!
+//! // Create functions signatures
+//! fn make_func_without_args() {
+//!		const SIG: FunctionSignature = make_signature!(
+//!			new fn(SIGNATURE_PREFERENCES),
+//!		);
+//!		let name = SIG.as_str();
+//!		similar_asserts::assert_eq!(name, "some_funk()");
+//!	}
+//!
+//! fn make_func_with_3_args() {
+//!		const SIG: FunctionSignature = make_signature!(
+//!			new fn(SIGNATURE_PREFERENCES),
+//!			(<u8>::SIGNATURE),
+//!			(<u8>::SIGNATURE),
+//!			(<Vec<u8>>::SIGNATURE),
+//!		);
+//!		let name = SIG.as_str();
+//!		similar_asserts::assert_eq!(name, "some_funk(uint8,uint8,uint8[])");
+//!	}
+//! ```
 use core::str::from_utf8;
 
+/// The maximum length of the signature.
 pub const SIGNATURE_SIZE_LIMIT: usize = 256;
 
+/// Function signature formatting preferences.
 #[derive(Debug)]
 pub struct SignaturePreferences {
+	/// The name of the function before the list of parameters: `*some*(param1,param2)func`
 	pub open_name: Option<SignatureUnit>,
+	/// Opening separator: `some*(*param1,param2)func`
 	pub open_delimiter: Option<SignatureUnit>,
+	/// Parameters separator: `some(param1*,*param2)func`
 	pub param_delimiter: Option<SignatureUnit>,
+	/// Closinging separator: `some(param1,param2*)*func`
 	pub close_delimiter: Option<SignatureUnit>,
+	/// The name of the function after the list of parameters: `some(param1,param2)*func*`
 	pub close_name: Option<SignatureUnit>,
 }
 
+/// Constructs and stores the signature of the function.
 #[derive(Debug)]
 pub struct FunctionSignature {
+	/// Storage for function signature.
 	pub unit: SignatureUnit,
 	preferences: SignaturePreferences,
 }
 
 impl FunctionSignature {
+	/// Start constructing the signature. It is written to the storage
+	/// [`SignaturePreferences::open_name`] and [`SignaturePreferences::open_delimiter`].
 	pub const fn new(preferences: SignaturePreferences) -> FunctionSignature {
 		let mut dst = [0_u8; SIGNATURE_SIZE_LIMIT];
 		let mut dst_offset = 0;
@@ -36,6 +153,8 @@
 		}
 	}
 
+	/// Add a function parameter to the signature. It is written to the storage
+	/// `param` [`SignatureUnit`] and [`SignaturePreferences::param_delimiter`].
 	pub const fn add_param(
 		signature: FunctionSignature,
 		param: SignatureUnit,
@@ -55,6 +174,8 @@
 		}
 	}
 
+	/// Complete signature construction. It is written to the storage
+	/// [`SignaturePreferences::close_delimiter`] and [`SignaturePreferences::close_name`].
 	pub const fn done(signature: FunctionSignature, owerride: bool) -> FunctionSignature {
 		let mut dst = signature.unit.data;
 		let mut dst_offset = signature.unit.len - if owerride { 1 } else { 0 };
@@ -73,18 +194,23 @@
 		}
 	}
 
+	/// Represent the signature as `&str'.
 	pub fn as_str(&self) -> &str {
 		from_utf8(&self.unit.data[..self.unit.len]).expect("bad utf-8")
 	}
 }
 
+/// Storage for the signature or its elements.
 #[derive(Debug)]
 pub struct SignatureUnit {
+	/// Signature data.
 	pub data: [u8; SIGNATURE_SIZE_LIMIT],
+	/// The actual size of the data.
 	pub len: usize,
 }
 
 impl SignatureUnit {
+	/// Create a signature from `&str'.
 	pub const fn new(name: &'static str) -> SignatureUnit {
 		let mut signature = [0_u8; SIGNATURE_SIZE_LIMIT];
 		let name = name.as_bytes();
@@ -98,9 +224,23 @@
 	}
 }
 
+/// ### Macro to create signatures of types and functions.
+///
+/// Format for creating a type of signature:
+/// ```ignore
+/// make_signature!(new fixed("uint8")); // Simple type
+/// make_signature!(new fixed("(") nameof(u8) fixed(",") nameof(u8) fixed(")")); // Composite type
+/// ```
+/// Format for creating a function of the function:
+/// ```ignore
+/// const SIG: FunctionSignature = make_signature!(
+///		new fn(SIGNATURE_PREFERENCES),
+///		(u8::SIGNATURE),
+///		(<(u8,u8)>::SIGNATURE),
+///	);
+/// ```
 #[macro_export]
-#[allow(missing_docs)]
-macro_rules! make_signature { // May be "define_signature"?
+macro_rules! make_signature {
 	(new fn($func:expr)$(,)+) => {
 		{
 			let fs = FunctionSignature::new($func);
@@ -283,10 +423,13 @@
 		assert_eq!(<MaxSize>::name(), "!".repeat(SIGNATURE_SIZE_LIMIT));
 	}
 
-	// This test must NOT compile!
+	// This test must NOT compile with "index out of bounds"!
 	// #[test]
 	// fn over_max_size() {
-	// 	assert_eq!(<Vec<MaxSize>>::name(), "!".repeat(SIZE_LIMIT) + "[]");
+	// 	assert_eq!(
+	// 		<Vec<MaxSize>>::name(),
+	// 		"!".repeat(SIGNATURE_SIZE_LIMIT) + "[]"
+	// 	);
 	// }
 
 	#[test]
modifiedcrates/evm-coder/src/lib.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/lib.rs
+++ b/crates/evm-coder/src/lib.rs
@@ -15,8 +15,7 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 #![doc = include_str!("../README.md")]
-// #![deny(missing_docs)]
-#![warn(missing_docs)]
+#![deny(missing_docs)]
 #![macro_use]
 #![cfg_attr(not(feature = "std"), no_std)]
 #[cfg(not(feature = "std"))]
@@ -94,7 +93,6 @@
 pub use evm_coder_procedural::solidity;
 /// See [`solidity_interface`]
 pub use evm_coder_procedural::weight;
-pub use const_format;
 pub use sha3_const;
 
 /// Derives [`ToLog`] for enum
@@ -384,18 +382,6 @@
 	fn function_selector_generation() {
 		assert_eq!(fn_selector!(transfer(address, uint256)), 0xa9059cbb);
 	}
-
-	// #[test]
-	// fn function_selector_generation_1() {
-	// 	assert_eq!(
-	// 		fn_selector!(transferFromCrossAccountToCrossAccount(
-	// 			EthCrossAccount,
-	// 			EthCrossAccount,
-	// 			uint256
-	// 		)),
-	// 		2543295963
-	// 	);
-	// }
 
 	#[test]
 	fn event_topic_generation() {
modifiedcrates/evm-coder/tests/conditional_is.rsdiffbeforeafterboth
--- a/crates/evm-coder/tests/conditional_is.rs
+++ b/crates/evm-coder/tests/conditional_is.rs
@@ -1,4 +1,11 @@
 use evm_coder::{types::*, solidity_interface, execution::Result};
+use evm_coder::{
+	make_signature,
+	custom_signature::{
+		SIGNATURE_SIZE_LIMIT, SignatureUnit, SignaturePreferences, FunctionSignature,
+	},
+	types::Signature,
+};
 
 pub struct Contract(bool);
 
modifiedcrates/evm-coder/tests/generics.rsdiffbeforeafterboth
--- a/crates/evm-coder/tests/generics.rs
+++ b/crates/evm-coder/tests/generics.rs
@@ -16,6 +16,12 @@
 
 use std::marker::PhantomData;
 use evm_coder::{execution::Result, generate_stubgen, solidity_interface, types::*};
+use evm_coder::{
+	make_signature,
+	custom_signature::{
+		SIGNATURE_SIZE_LIMIT, SignatureUnit, SignaturePreferences, FunctionSignature,
+	},
+};
 
 pub struct Generic<T>(PhantomData<T>);
 
modifiedcrates/evm-coder/tests/random.rsdiffbeforeafterboth
--- a/crates/evm-coder/tests/random.rs
+++ b/crates/evm-coder/tests/random.rs
@@ -17,6 +17,13 @@
 #![allow(dead_code)] // This test only checks that macros is not panicking
 
 use evm_coder::{ToLog, execution::Result, solidity_interface, types::*, solidity, weight};
+use evm_coder::{
+	make_signature,
+	custom_signature::{
+		SIGNATURE_SIZE_LIMIT, SignatureUnit, SignaturePreferences, FunctionSignature,
+	},
+	types::Signature,
+};
 
 pub struct Impls;
 
modifiedcrates/evm-coder/tests/solidity_generation.rsdiffbeforeafterboth
--- a/crates/evm-coder/tests/solidity_generation.rs
+++ b/crates/evm-coder/tests/solidity_generation.rs
@@ -15,6 +15,13 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 use evm_coder::{execution::Result, generate_stubgen, solidity_interface, types::*};
+use evm_coder::{
+	make_signature,
+	custom_signature::{
+		SIGNATURE_SIZE_LIMIT, SignatureUnit, SignaturePreferences, FunctionSignature,
+	},
+	types::Signature,
+};
 
 pub struct ERC20;
 
modifiedtests/src/eth/base.test.tsdiffbeforeafterboth
before · tests/src/eth/base.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 {IKeyringPair} from '@polkadot/types/types';18import {EthUniqueHelper, itEth, usingEthPlaygrounds, expect} from './util';192021describe('Contract calls', () => {22  let donor: IKeyringPair;2324  before(async function () {25    await usingEthPlaygrounds(async (_helper, privateKey) => {26      donor = await privateKey({filename: __filename});27    });28  });2930  itEth('Call of simple contract fee is less than 0.2 UNQ', async ({helper}) => {31    const deployer = await helper.eth.createAccountWithBalance(donor);32    const flipper = await helper.eth.deployFlipper(deployer);3334    const cost = await helper.eth.calculateFee({Ethereum: deployer}, () => flipper.methods.flip().send({from: deployer}));35    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal()))).to.be.true;36  });3738  itEth('Balance transfer fee is less than 0.2 UNQ', async ({helper}) => {39    const userA = await helper.eth.createAccountWithBalance(donor);40    const userB = helper.eth.createAccount();41    const cost = await helper.eth.calculateFee({Ethereum: userA}, () => helper.getWeb3().eth.sendTransaction({42      from: userA,43      to: userB,44      value: '1000000',45      gas: helper.eth.DEFAULT_GAS,46    }));47    const balanceB = await helper.balance.getEthereum(userB);48    expect(cost - balanceB < BigInt(0.2 * Number(helper.balance.getOneTokenNominal()))).to.be.true;49  });5051  itEth('NFT transfer is close to 0.15 UNQ', async ({helper}) => {52    const caller = await helper.eth.createAccountWithBalance(donor);53    const receiver = helper.eth.createAccount();5455    const [alice] = await helper.arrange.createAccounts([10n], donor);56    const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});57    const {tokenId} = await collection.mintToken(alice, {Ethereum: caller});5859    const address = helper.ethAddress.fromCollectionId(collection.collectionId);60    const contract = helper.ethNativeContract.collection(address, 'nft', caller);6162    const cost = await helper.eth.calculateFee({Ethereum: caller}, () => contract.methods.transfer(receiver, tokenId).send(caller));6364    const fee = Number(cost) / Number(helper.balance.getOneTokenNominal());65    const expectedFee = 0.15;66    const tolerance = 0.001;6768    expect(Math.abs(fee - expectedFee)).to.be.lessThan(tolerance);69  });70});7172describe('ERC165 tests', async () => {73  // https://eips.ethereum.org/EIPS/eip-1657475  let erc721MetadataCompatibleNftCollectionId: number;76  let simpleNftCollectionId: number;77  let minter: string;7879  const BASE_URI = 'base/';8081  async function checkInterface(helper: EthUniqueHelper, interfaceId: string, simpleResult: boolean, compatibleResult: boolean) {82    const simple = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(simpleNftCollectionId), 'nft', minter);83    const compatible = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(erc721MetadataCompatibleNftCollectionId), 'nft', minter);8485    expect(await simple.methods.supportsInterface(interfaceId).call()).to.equal(simpleResult, `empty (not ERC721Metadata compatible) NFT collection returns not ${simpleResult}`);86    expect(await compatible.methods.supportsInterface(interfaceId).call()).to.equal(compatibleResult, `ERC721Metadata compatible NFT collection returns not ${compatibleResult}`);87  }8889  before(async () => {90    await usingEthPlaygrounds(async (helper, privateKey) => {91      const donor = await privateKey({filename: __filename});92      const [alice] = await helper.arrange.createAccounts([10n], donor);93      ({collectionId: simpleNftCollectionId} = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'}));94      minter = await helper.eth.createAccountWithBalance(donor);95      ({collectionId: erc721MetadataCompatibleNftCollectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(minter, 'n', 'd', 'p', BASE_URI));96    });97  });9899  itEth('nonexistent interfaceID - 0xffffffff - always false', async ({helper}) => {100    await checkInterface(helper, '0xffffffff', false, false);101  });102103  itEth('ERC721 - 0x780e9d63 - support', async ({helper}) => {104    await checkInterface(helper, '0x780e9d63', true, true);105  });106107  itEth('ERC721Metadata - 0x5b5e139f - support', async ({helper}) => {108    await checkInterface(helper, '0x5b5e139f', false, true);109  });110111  itEth('ERC721UniqueMintable - 0x476ff149 - support', async ({helper}) => {112    await checkInterface(helper, '0x476ff149', true, true);113  });114115  itEth('ERC721Enumerable - 0x780e9d63 - support', async ({helper}) => {116    await checkInterface(helper, '0x780e9d63', true, true);117  });118119  itEth('ERC721UniqueExtensions - 0x244543ee - support', async ({helper}) => {120    await checkInterface(helper, '0x244543ee', true, true);121  });122123  itEth('ERC721Burnable - 0x42966c68 - support', async ({helper}) => {124    await checkInterface(helper, '0x42966c68', true, true);125  });126127  itEth('ERC165 - 0x01ffc9a7 - support', async ({helper}) => {128    await checkInterface(helper, '0x01ffc9a7', true, true);129  });130});
after · tests/src/eth/base.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 {IKeyringPair} from '@polkadot/types/types';18import {EthUniqueHelper, itEth, usingEthPlaygrounds, expect} from './util';192021describe('Contract calls', () => {22  let donor: IKeyringPair;2324  before(async function () {25    await usingEthPlaygrounds(async (_helper, privateKey) => {26      donor = await privateKey({filename: __filename});27    });28  });2930  itEth('Call of simple contract fee is less than 0.2 UNQ', async ({helper}) => {31    const deployer = await helper.eth.createAccountWithBalance(donor);32    const flipper = await helper.eth.deployFlipper(deployer);3334    const cost = await helper.eth.calculateFee({Ethereum: deployer}, () => flipper.methods.flip().send({from: deployer}));35    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal()))).to.be.true;36  });3738  itEth('Balance transfer fee is less than 0.2 UNQ', async ({helper}) => {39    const userA = await helper.eth.createAccountWithBalance(donor);40    const userB = helper.eth.createAccount();41    const cost = await helper.eth.calculateFee({Ethereum: userA}, () => helper.getWeb3().eth.sendTransaction({42      from: userA,43      to: userB,44      value: '1000000',45      gas: helper.eth.DEFAULT_GAS,46    }));47    const balanceB = await helper.balance.getEthereum(userB);48    expect(cost - balanceB < BigInt(0.2 * Number(helper.balance.getOneTokenNominal()))).to.be.true;49  });5051  itEth('NFT transfer is close to 0.15 UNQ', async ({helper}) => {52    const caller = await helper.eth.createAccountWithBalance(donor);53    const receiver = helper.eth.createAccount();5455    const [alice] = await helper.arrange.createAccounts([10n], donor);56    const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});57    const {tokenId} = await collection.mintToken(alice, {Ethereum: caller});5859    const address = helper.ethAddress.fromCollectionId(collection.collectionId);60    const contract = helper.ethNativeContract.collection(address, 'nft', caller);6162    const cost = await helper.eth.calculateFee({Ethereum: caller}, () => contract.methods.transfer(receiver, tokenId).send(caller));6364    const fee = Number(cost) / Number(helper.balance.getOneTokenNominal());65    const expectedFee = 0.15;66    const tolerance = 0.001;6768    expect(Math.abs(fee - expectedFee)).to.be.lessThan(tolerance);69  });70});7172describe('ERC165 tests', async () => {73  // https://eips.ethereum.org/EIPS/eip-1657475  let erc721MetadataCompatibleNftCollectionId: number;76  let simpleNftCollectionId: number;77  let minter: string;7879  const BASE_URI = 'base/';8081  async function checkInterface(helper: EthUniqueHelper, interfaceId: string, simpleResult: boolean, compatibleResult: boolean) {82    const simple = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(simpleNftCollectionId), 'nft', minter);83    const compatible = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(erc721MetadataCompatibleNftCollectionId), 'nft', minter);8485    expect(await simple.methods.supportsInterface(interfaceId).call()).to.equal(simpleResult, `empty (not ERC721Metadata compatible) NFT collection returns not ${simpleResult}`);86    expect(await compatible.methods.supportsInterface(interfaceId).call()).to.equal(compatibleResult, `ERC721Metadata compatible NFT collection returns not ${compatibleResult}`);87  }8889  before(async () => {90    await usingEthPlaygrounds(async (helper, privateKey) => {91      const donor = await privateKey({filename: __filename});92      const [alice] = await helper.arrange.createAccounts([10n], donor);93      ({collectionId: simpleNftCollectionId} = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'}));94      minter = await helper.eth.createAccountWithBalance(donor);95      ({collectionId: erc721MetadataCompatibleNftCollectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(minter, 'n', 'd', 'p', BASE_URI));96    });97  });9899  itEth('nonexistent interfaceID - 0xffffffff - always false', async ({helper}) => {100    await checkInterface(helper, '0xffffffff', false, false);101  });102103  itEth('ERC721 - 0x780e9d63 - support', async ({helper}) => {104    await checkInterface(helper, '0x780e9d63', true, true);105  });106107  itEth('ERC721Metadata - 0x5b5e139f - support', async ({helper}) => {108    await checkInterface(helper, '0x5b5e139f', false, true);109  });110111  itEth('ERC721UniqueMintable - 0x476ff149 - support', async ({helper}) => {112    await checkInterface(helper, '0x476ff149', true, true);113  });114115  itEth('ERC721Enumerable - 0x780e9d63 - support', async ({helper}) => {116    await checkInterface(helper, '0x780e9d63', true, true);117  });118119  itEth('ERC721UniqueExtensions support', async ({helper}) => {120    expect(await contract(helper).methods.supportsInterface('0xb76006ac').call()).to.be.true;121  });122123  itEth('ERC721Burnable - 0x42966c68 - support', async ({helper}) => {124    await checkInterface(helper, '0x42966c68', true, true);125  });126127  itEth('ERC165 - 0x01ffc9a7 - support', async ({helper}) => {128    await checkInterface(helper, '0x01ffc9a7', true, true);129  });130});
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -410,14 +410,13 @@
   });
 
   itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {
-    const alice = privateKey('//Alice');
-    const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
+    const collection = await helper.nft.mintCollection(donor, {name: 'A', description: 'B', tokenPrefix: 'C'});
 
     const owner = privateKey('//Bob');
-    const spender = await helper.eth.createAccountWithBalance(alice, 100n);
+    const spender = await helper.eth.createAccountWithBalance(donor, 100n);
     const receiver = privateKey('//Charlie');
 
-    const token = await collection.mintToken(alice, {Substrate: owner.address});
+    const token = await collection.mintToken(donor, {Substrate: owner.address});
 
     const address = helper.ethAddress.fromCollectionId(collection.collectionId);
     const contract = helper.ethNativeContract.collection(address, 'nft');
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -295,14 +295,13 @@
   });
 
   itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {
-    const alice = privateKey('//Alice');
-    const collection = await helper.rft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
+    const collection = await helper.rft.mintCollection(donor, {name: 'A', description: 'B', tokenPrefix: 'C'});
 
     const owner = privateKey('//Bob');
-    const spender = await helper.eth.createAccountWithBalance(alice, 100n);
+    const spender = await helper.eth.createAccountWithBalance(donor, 100n);
     const receiver = privateKey('//Charlie');
 
-    const token = await collection.mintToken(alice, 100n, {Substrate: owner.address});
+    const token = await collection.mintToken(donor, 100n, {Substrate: owner.address});
 
     const address = helper.ethAddress.fromCollectionId(collection.collectionId);
     const contract = helper.ethNativeContract.collection(address, 'rft');