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

difftreelog

refactor switch to new eth log logic

Yaroslav Bolyukin2022-05-13parent: #b8e5671.patch.diff
in: master

33 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2555,7 +2555,7 @@
 [[package]]
 name = "fc-consensus"
 version = "2.0.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a"
+source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475"
 dependencies = [
  "async-trait",
  "fc-db",
@@ -2574,7 +2574,7 @@
 [[package]]
 name = "fc-db"
 version = "2.0.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a"
+source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475"
 dependencies = [
  "fp-storage",
  "kvdb-rocksdb",
@@ -2588,7 +2588,7 @@
 [[package]]
 name = "fc-mapping-sync"
 version = "2.0.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a"
+source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475"
 dependencies = [
  "fc-db",
  "fp-consensus",
@@ -2605,7 +2605,7 @@
 [[package]]
 name = "fc-rpc"
 version = "2.0.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a"
+source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475"
 dependencies = [
  "ethereum",
  "ethereum-types",
@@ -2644,7 +2644,7 @@
 [[package]]
 name = "fc-rpc-core"
 version = "1.1.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a"
+source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475"
 dependencies = [
  "ethereum",
  "ethereum-types",
@@ -2777,7 +2777,7 @@
 [[package]]
 name = "fp-consensus"
 version = "2.0.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a"
+source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475"
 dependencies = [
  "ethereum",
  "parity-scale-codec",
@@ -2789,7 +2789,7 @@
 [[package]]
 name = "fp-evm"
 version = "3.0.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a"
+source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475"
 dependencies = [
  "evm",
  "impl-trait-for-tuples",
@@ -2802,7 +2802,7 @@
 [[package]]
 name = "fp-evm-mapping"
 version = "0.1.0"
-source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a"
+source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475"
 dependencies = [
  "frame-support",
  "sp-core",
@@ -2811,7 +2811,7 @@
 [[package]]
 name = "fp-rpc"
 version = "3.0.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a"
+source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475"
 dependencies = [
  "ethereum",
  "ethereum-types",
@@ -2828,7 +2828,7 @@
 [[package]]
 name = "fp-self-contained"
 version = "1.0.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a"
+source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475"
 dependencies = [
  "ethereum",
  "frame-support",
@@ -2844,7 +2844,7 @@
 [[package]]
 name = "fp-storage"
 version = "2.0.0"
-source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a"
+source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475"
 dependencies = [
  "parity-scale-codec",
 ]
@@ -5741,7 +5741,7 @@
 [[package]]
 name = "pallet-base-fee"
 version = "1.0.0"
-source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a"
+source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475"
 dependencies = [
  "fp-evm",
  "frame-support",
@@ -5999,7 +5999,7 @@
 [[package]]
 name = "pallet-ethereum"
 version = "4.0.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a"
+source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475"
 dependencies = [
  "ethereum",
  "ethereum-types",
@@ -6029,7 +6029,7 @@
 [[package]]
 name = "pallet-evm"
 version = "6.0.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a"
+source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475"
 dependencies = [
  "evm",
  "fp-evm",
modifiedclient/rpc/Cargo.tomldiffbeforeafterboth
--- a/client/rpc/Cargo.toml
+++ b/client/rpc/Cargo.toml
@@ -18,4 +18,4 @@
 sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 sp-rpc = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
-pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
modifiednode/cli/Cargo.tomldiffbeforeafterboth
--- a/node/cli/Cargo.toml
+++ b/node/cli/Cargo.toml
@@ -306,13 +306,13 @@
 jsonrpc-pubsub = "18.0.0"
 tokio = { version = "1.17.0", features = ["time"] }
 
-fc-rpc-core = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-fc-consensus = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-fc-mapping-sync = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-fc-rpc = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-fc-db = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-fp-rpc = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-pallet-ethereum = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+fc-rpc-core = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+fc-consensus = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+fc-mapping-sync = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+fc-rpc = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+fc-db = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+fp-rpc = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+pallet-ethereum = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 
 unique-rpc = { default-features = false, path = "../rpc" }
 
modifiednode/rpc/Cargo.tomldiffbeforeafterboth
--- a/node/rpc/Cargo.toml
+++ b/node/rpc/Cargo.toml
@@ -41,13 +41,13 @@
 substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 tokio = { version = "0.2.25", features = ["macros", "sync"] }
 
-pallet-ethereum = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-fc-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-fp-storage = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-fc-rpc-core = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-fc-db = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-fc-mapping-sync = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+pallet-ethereum = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+fc-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+fp-storage = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+fc-rpc-core = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+fc-db = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+fc-mapping-sync = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 
 pallet-common = { default-features = false, path = "../../pallets/common" }
 unique-runtime-common = { default-features = false, path = "../../runtime/common" }
modifiedpallets/common/Cargo.tomldiffbeforeafterboth
--- a/pallets/common/Cargo.toml
+++ b/pallets/common/Cargo.toml
@@ -16,11 +16,11 @@
 sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
-fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 up-data-structs = { default-features = false, path = '../../primitives/data-structs' }
 pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }
 evm-coder = { default-features = false, path = '../../crates/evm-coder' }
-pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 serde = { version = "1.0.130", default-features = false }
 scale-info = { version = "2.0.1", default-features = false, features = [
     "derive",
modifiedpallets/common/src/dispatch.rsdiffbeforeafterboth
--- a/pallets/common/src/dispatch.rs
+++ b/pallets/common/src/dispatch.rs
@@ -52,8 +52,6 @@
 		}) => *weight += dispatch_weight::<T>(),
 		_ => {}
 	}
-
-	dispatched.into_inner().submit_logs();
 	result
 }
 
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -66,7 +66,7 @@
 		<CollectionById<T>>::get(id).map(|collection| Self {
 			id,
 			collection,
-			recorder: SubstrateRecorder::new(eth::collection_id_to_address(id), gas_limit),
+			recorder: SubstrateRecorder::new(gas_limit),
 		})
 	}
 	pub fn new(id: CollectionId) -> Option<Self> {
@@ -74,12 +74,6 @@
 	}
 	pub fn try_get(id: CollectionId) -> Result<Self, DispatchError> {
 		Ok(Self::new(id).ok_or(<Error<T>>::CollectionNotFound)?)
-	}
-	pub fn log_mirrored(&self, log: impl evm_coder::ToLog) {
-		self.recorder.log_mirrored(log)
-	}
-	pub fn log_direct(&self, log: impl evm_coder::ToLog) {
-		self.recorder.log_direct(log)
 	}
 	pub fn consume_store_reads(&self, reads: u64) -> evm_coder::execution::Result<()> {
 		self.recorder
@@ -96,12 +90,8 @@
 					.write
 					.saturating_mul(writes),
 			))
-	}
-	pub fn submit_logs(self) {
-		self.recorder.submit_logs()
 	}
 	pub fn save(self) -> DispatchResult {
-		self.recorder.submit_logs();
 		<CollectionById<T>>::insert(self.id, self.collection);
 		Ok(())
 	}
modifiedpallets/evm-coder-substrate/Cargo.tomldiffbeforeafterboth
--- a/pallets/evm-coder-substrate/Cargo.toml
+++ b/pallets/evm-coder-substrate/Cargo.toml
@@ -12,8 +12,8 @@
 sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 ethereum = { version = "0.12.0", default-features = false }
 evm-coder = { default-features = false, path = "../../crates/evm-coder" }
-pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
modifiedpallets/evm-coder-substrate/src/lib.rsdiffbeforeafterboth
--- a/pallets/evm-coder-substrate/src/lib.rs
+++ b/pallets/evm-coder-substrate/src/lib.rs
@@ -24,7 +24,6 @@
 
 use core::marker::PhantomData;
 use sp_std::cell::RefCell;
-use sp_std::vec::Vec;
 
 use codec::Decode;
 use frame_support::pallet_prelude::DispatchError;
@@ -33,15 +32,13 @@
 use up_data_structs::budget;
 use pallet_evm::{
 	ExitError, ExitRevert, ExitSucceed, GasWeightMapping, PrecompileFailure, PrecompileOutput,
-	PrecompileResult, runner::stack::MaybeMirroredLog,
+	PrecompileResult,
 };
 use sp_core::H160;
-use pallet_ethereum::EthereumTransactionSender;
 // #[cfg(feature = "runtime-benchmarks")]
 // pub mod benchmarking;
 
 use evm_coder::{
-	ToLog,
 	abi::{AbiReader, AbiWrite, AbiWriter},
 	execution::{self, Result},
 	types::{Msg, value},
@@ -70,7 +67,6 @@
 
 	#[pallet::config]
 	pub trait Config: frame_system::Config {
-		type EthereumTransactionSender: pallet_ethereum::EthereumTransactionSender;
 		type GasWeightMapping: pallet_evm::GasWeightMapping;
 	}
 
@@ -107,43 +103,20 @@
 
 #[derive(Default)]
 pub struct SubstrateRecorder<T: Config> {
-	contract: H160,
-	logs: RefCell<Vec<MaybeMirroredLog>>,
 	initial_gas: u64,
 	gas_limit: RefCell<u64>,
 	_phantom: PhantomData<*const T>,
 }
 
 impl<T: Config> SubstrateRecorder<T> {
-	pub fn new(contract: H160, gas_limit: u64) -> Self {
+	pub fn new(gas_limit: u64) -> Self {
 		Self {
-			contract,
-			logs: RefCell::new(Vec::new()),
 			initial_gas: gas_limit,
 			gas_limit: RefCell::new(gas_limit),
 			_phantom: PhantomData,
 		}
 	}
 
-	pub fn is_empty(&self) -> bool {
-		self.logs.borrow().is_empty()
-	}
-	// Logs emitted with log_direct appear as substrate evm.Log event
-	pub fn log_direct(&self, log: impl ToLog) {
-		self.logs
-			.borrow_mut()
-			.push(MaybeMirroredLog::direct(log.to_log(self.contract)))
-	}
-	/// If log already has substrate equivalent - then we don't need to emit evm.Log
-	pub fn log_mirrored(&self, log: impl ToLog) {
-		self.logs
-			.borrow_mut()
-			.push(MaybeMirroredLog::mirrored(log.to_log(self.contract)))
-	}
-	pub fn retrieve_logs(self) -> Vec<MaybeMirroredLog> {
-		self.logs.into_inner()
-	}
-
 	pub fn gas_left(&self) -> u64 {
 		*self.gas_limit.borrow()
 	}
@@ -207,8 +180,8 @@
 			Ok(Some(v)) => Ok(PrecompileOutput {
 				exit_status: ExitSucceed::Returned,
 				cost: self.initial_gas - self.gas_left(),
-				// TODO: preserve mirroring status
-				logs: self.retrieve_logs().into_iter().map(|l| l.log).collect(),
+				// We don't use this interface
+				logs: sp_std::vec![],
 				output: v.finish(),
 			}),
 			Ok(None) => return None,
@@ -225,14 +198,6 @@
 			Err(Error::Fatal(f)) => Err(f.into()),
 			Err(Error::Error(e)) => Err(e.into()),
 		})
-	}
-
-	pub fn submit_logs(self) {
-		let logs = self.retrieve_logs();
-		if logs.is_empty() {
-			return;
-		}
-		T::EthereumTransactionSender::submit_logs_transaction(Default::default(), logs)
 	}
 }
 
modifiedpallets/evm-contract-helpers/Cargo.tomldiffbeforeafterboth
--- a/pallets/evm-contract-helpers/Cargo.toml
+++ b/pallets/evm-contract-helpers/Cargo.toml
@@ -15,8 +15,8 @@
 sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 evm-coder = { default-features = false, path = '../../crates/evm-coder' }
 pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }
-pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.21" }
 log = "0.4.14"
 
modifiedpallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth
--- a/pallets/evm-contract-helpers/src/eth.rs
+++ b/pallets/evm-contract-helpers/src/eth.rs
@@ -162,7 +162,7 @@
 			return None;
 		}
 
-		let helpers = ContractHelpers::<T>(SubstrateRecorder::<T>::new(*target, gas_left));
+		let helpers = ContractHelpers::<T>(SubstrateRecorder::<T>::new(gas_left));
 		pallet_evm_coder_substrate::call(*source, helpers, value, input)
 	}
 
modifiedpallets/evm-migration/Cargo.tomldiffbeforeafterboth
--- a/pallets/evm-migration/Cargo.toml
+++ b/pallets/evm-migration/Cargo.toml
@@ -15,8 +15,8 @@
 sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
-pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 
 [dependencies.codec]
 default-features = false
modifiedpallets/evm-migration/src/lib.rsdiffbeforeafterboth
--- a/pallets/evm-migration/src/lib.rs
+++ b/pallets/evm-migration/src/lib.rs
@@ -28,6 +28,7 @@
 	use sp_core::{H160, H256};
 	use sp_std::vec::Vec;
 	use super::weights::WeightInfo;
+	use pallet_evm::Pallet as PalletEvm;
 
 	#[pallet::config]
 	pub trait Config: frame_system::Config + pallet_evm::Config {
@@ -56,8 +57,7 @@
 		pub fn begin(origin: OriginFor<T>, address: H160) -> DispatchResult {
 			ensure_root(origin)?;
 			ensure!(
-				<pallet_evm::Pallet<T>>::is_account_empty(&address)
-					&& !<MigrationPending<T>>::get(&address),
+				<PalletEvm<T>>::is_account_empty(&address) && !<MigrationPending<T>>::get(&address),
 				<Error<T>>::AccountNotEmpty,
 			);
 
modifiedpallets/evm-transaction-payment/Cargo.tomldiffbeforeafterboth
--- a/pallets/evm-transaction-payment/Cargo.toml
+++ b/pallets/evm-transaction-payment/Cargo.toml
@@ -14,11 +14,11 @@
 sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
-pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.21" }
-fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 
 [dependencies.codec]
 default-features = false
modifiedpallets/fungible/Cargo.tomldiffbeforeafterboth
--- a/pallets/fungible/Cargo.toml
+++ b/pallets/fungible/Cargo.toml
@@ -23,7 +23,7 @@
 pallet-evm-coder-substrate = { default-features = false, path = '../evm-coder-substrate' }
 ethereum = { version = "0.12.0", default-features = false }
 frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
-pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 scale-info = { version = "2.0.1", default-features = false, features = [
     "derive",
 ] }
modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -17,6 +17,7 @@
 #![cfg_attr(not(feature = "std"), no_std)]
 
 use core::ops::Deref;
+use evm_coder::ToLog;
 use frame_support::{ensure};
 use pallet_evm::account::CrossAccountId;
 use up_data_structs::{
@@ -25,8 +26,9 @@
 };
 use pallet_common::{
 	Error as CommonError, Event as CommonEvent, Pallet as PalletCommon, CollectionHandle,
-	dispatch::CollectionDispatch,
+	dispatch::CollectionDispatch, eth::collection_id_to_address,
 };
+use pallet_evm::Pallet as PalletEvm;
 use pallet_structure::Pallet as PalletStructure;
 use pallet_evm_coder_substrate::WithRecorder;
 use sp_core::H160;
@@ -67,7 +69,7 @@
 
 	#[pallet::config]
 	pub trait Config:
-		frame_system::Config + pallet_common::Config + pallet_structure::Config
+		frame_system::Config + pallet_common::Config + pallet_structure::Config + pallet_evm::Config
 	{
 		type WeightInfo: WeightInfo;
 	}
@@ -179,11 +181,14 @@
 		}
 		<TotalSupply<T>>::insert(collection.id, total_supply);
 
-		collection.log_mirrored(ERC20Events::Transfer {
-			from: *owner.as_eth(),
-			to: H160::default(),
-			value: amount.into(),
-		});
+		<PalletEvm<T>>::deposit_log(
+			ERC20Events::Transfer {
+				from: *owner.as_eth(),
+				to: H160::default(),
+				value: amount.into(),
+			}
+			.to_log(collection_id_to_address(collection.id)),
+		);
 		<PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(
 			collection.id,
 			TokenId::default(),
@@ -249,11 +254,14 @@
 			<Balance<T>>::insert((collection.id, to), balance_to);
 		}
 
-		collection.log_mirrored(ERC20Events::Transfer {
-			from: *from.as_eth(),
-			to: *to.as_eth(),
-			value: amount.into(),
-		});
+		<PalletEvm<T>>::deposit_log(
+			ERC20Events::Transfer {
+				from: *from.as_eth(),
+				to: *to.as_eth(),
+				value: amount.into(),
+			}
+			.to_log(collection_id_to_address(collection.id)),
+		);
 		<PalletCommon<T>>::deposit_event(CommonEvent::Transfer(
 			collection.id,
 			TokenId::default(),
@@ -318,11 +326,14 @@
 		for (user, amount) in balances {
 			<Balance<T>>::insert((collection.id, &user), amount);
 
-			collection.log_mirrored(ERC20Events::Transfer {
-				from: H160::default(),
-				to: *user.as_eth(),
-				value: amount.into(),
-			});
+			<PalletEvm<T>>::deposit_log(
+				ERC20Events::Transfer {
+					from: H160::default(),
+					to: *user.as_eth(),
+					value: amount.into(),
+				}
+				.to_log(collection_id_to_address(collection.id)),
+			);
 			<PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(
 				collection.id,
 				TokenId::default(),
@@ -346,11 +357,14 @@
 			<Allowance<T>>::insert((collection.id, owner, spender), amount);
 		}
 
-		collection.log_mirrored(ERC20Events::Approval {
-			owner: *owner.as_eth(),
-			spender: *spender.as_eth(),
-			value: amount.into(),
-		});
+		<PalletEvm<T>>::deposit_log(
+			ERC20Events::Approval {
+				owner: *owner.as_eth(),
+				spender: *spender.as_eth(),
+				value: amount.into(),
+			}
+			.to_log(collection_id_to_address(collection.id)),
+		);
 		<PalletCommon<T>>::deposit_event(CommonEvent::Approved(
 			collection.id,
 			TokenId(0),
modifiedpallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth
--- a/pallets/fungible/src/stubs/UniqueFungible.sol
+++ b/pallets/fungible/src/stubs/UniqueFungible.sol
@@ -8,13 +8,8 @@
 	uint8 dummy;
 	string stub_error = "this contract is implemented in native";
 }
-
 contract ERC165 is Dummy {
-	function supportsInterface(bytes4 interfaceID)
-		external
-		view
-		returns (bool)
-	{
+	function supportsInterface(bytes4 interfaceID) external view returns (bool) {
 		require(false, stub_error);
 		interfaceID;
 		return true;
@@ -24,11 +19,36 @@
 // Inline
 contract ERC20Events {
 	event Transfer(address indexed from, address indexed to, uint256 value);
-	event Approval(
-		address indexed owner,
-		address indexed spender,
-		uint256 value
-	);
+	event Approval(address indexed owner, address indexed spender, uint256 value);
+}
+
+// Selector: 56fd500b
+contract CollectionProperties is Dummy, ERC165 {
+	// Selector: setProperty(string,string) 62d9491f
+	function setProperty(string memory key, string memory value) public {
+		require(false, stub_error);
+		key;
+		value;
+		dummy = 0;
+	}
+	// Selector: deleteProperty(string) 34241914
+	function deleteProperty(string memory key) public {
+		require(false, stub_error);
+		key;
+		dummy = 0;
+	}
+}
+
+// Selector: 79cc6790
+contract ERC20UniqueExtensions is Dummy, ERC165 {
+	// Selector: burnFrom(address,uint256) 79cc6790
+	function burnFrom(address from, uint256 amount) public returns (bool) {
+		require(false, stub_error);
+		from;
+		amount;
+		dummy = 0;
+		return false;
+	}
 }
 
 // Selector: 942e8b22
@@ -39,28 +59,24 @@
 		dummy;
 		return "";
 	}
-
 	// Selector: symbol() 95d89b41
 	function symbol() public view returns (string memory) {
 		require(false, stub_error);
 		dummy;
 		return "";
 	}
-
 	// Selector: totalSupply() 18160ddd
 	function totalSupply() public view returns (uint256) {
 		require(false, stub_error);
 		dummy;
 		return 0;
 	}
-
 	// Selector: decimals() 313ce567
 	function decimals() public view returns (uint8) {
 		require(false, stub_error);
 		dummy;
 		return 0;
 	}
-
 	// Selector: balanceOf(address) 70a08231
 	function balanceOf(address owner) public view returns (uint256) {
 		require(false, stub_error);
@@ -68,7 +84,6 @@
 		dummy;
 		return 0;
 	}
-
 	// Selector: transfer(address,uint256) a9059cbb
 	function transfer(address to, uint256 amount) public returns (bool) {
 		require(false, stub_error);
@@ -77,13 +92,8 @@
 		dummy = 0;
 		return false;
 	}
-
 	// Selector: transferFrom(address,address,uint256) 23b872dd
-	function transferFrom(
-		address from,
-		address to,
-		uint256 amount
-	) public returns (bool) {
+	function transferFrom(address from, address to, uint256 amount) public returns (bool) {
 		require(false, stub_error);
 		from;
 		to;
@@ -91,7 +101,6 @@
 		dummy = 0;
 		return false;
 	}
-
 	// Selector: approve(address,uint256) 095ea7b3
 	function approve(address spender, uint256 amount) public returns (bool) {
 		require(false, stub_error);
@@ -100,13 +109,8 @@
 		dummy = 0;
 		return false;
 	}
-
 	// Selector: allowance(address,address) dd62ed3e
-	function allowance(address owner, address spender)
-		public
-		view
-		returns (uint256)
-	{
+	function allowance(address owner, address spender) public view returns (uint256) {
 		require(false, stub_error);
 		owner;
 		spender;
@@ -115,4 +119,6 @@
 	}
 }
 
-contract UniqueFungible is Dummy, ERC165, ERC20 {}
+contract UniqueFungible is Dummy, ERC165, ERC20, ERC20UniqueExtensions, CollectionProperties {
+}
+
modifiedpallets/nonfungible/Cargo.tomldiffbeforeafterboth
--- a/pallets/nonfungible/Cargo.toml
+++ b/pallets/nonfungible/Cargo.toml
@@ -16,7 +16,7 @@
 sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
-pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 pallet-common = { default-features = false, path = '../common' }
 pallet-structure = { default-features = false, path = '../structure' }
 up-data-structs = { default-features = false, path = '../../primitives/data-structs' }
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
before · pallets/nonfungible/src/lib.rs
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/>.1617#![cfg_attr(not(feature = "std"), no_std)]1819use erc::ERC721Events;20use frame_support::{BoundedVec, ensure, fail};21use up_data_structs::{22	AccessMode, CollectionId, CustomDataLimit, TokenId, CreateCollectionData, CreateNftExData,23	mapping::TokenAddressMapping, NestingRule, budget::Budget, Property, PropertyPermission,24	PropertyKey, PropertyKeyPermission, Properties, TrySet,25};26use pallet_evm::account::CrossAccountId;27use pallet_common::{28	Error as CommonError, Pallet as PalletCommon, Event as CommonEvent, CollectionHandle,29	dispatch::CollectionDispatch,30};31use pallet_structure::Pallet as PalletStructure;32use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};33use sp_core::H160;34use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};35use sp_std::{vec::Vec, vec};36use core::ops::Deref;37use sp_std::collections::btree_map::BTreeMap;38use codec::{Encode, Decode, MaxEncodedLen};39use scale_info::TypeInfo;4041pub use pallet::*;42#[cfg(feature = "runtime-benchmarks")]43pub mod benchmarking;44pub mod common;45pub mod erc;46pub mod weights;4748pub type CreateItemData<T> = CreateNftExData<<T as pallet_evm::account::Config>::CrossAccountId>;49pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;5051#[derive(Encode, Decode, TypeInfo, MaxEncodedLen)]52pub struct ItemData<CrossAccountId> {53	pub const_data: BoundedVec<u8, CustomDataLimit>,54	pub variable_data: BoundedVec<u8, CustomDataLimit>,55	pub owner: CrossAccountId,56}5758#[frame_support::pallet]59pub mod pallet {60	use super::*;61	use frame_support::{Blake2_128Concat, Twox64Concat, pallet_prelude::*, storage::Key};62	use up_data_structs::{CollectionId, TokenId};63	use super::weights::WeightInfo;6465	#[pallet::error]66	pub enum Error<T> {67		/// Not Nonfungible item data used to mint in Nonfungible collection.68		NotNonfungibleDataUsedToMintFungibleCollectionToken,69		/// Used amount > 1 with NFT70		NonfungibleItemsHaveNoAmount,71	}7273	#[pallet::config]74	pub trait Config:75		frame_system::Config + pallet_common::Config + pallet_structure::Config76	{77		type WeightInfo: WeightInfo;78	}7980	#[pallet::pallet]81	#[pallet::generate_store(pub(super) trait Store)]82	pub struct Pallet<T>(_);8384	#[pallet::storage]85	pub type TokensMinted<T: Config> =86		StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;87	#[pallet::storage]88	pub type TokensBurnt<T: Config> =89		StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;9091	#[pallet::storage]92	pub type TokenData<T: Config> = StorageNMap<93		Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),94		Value = ItemData<T::CrossAccountId>,95		QueryKind = OptionQuery,96	>;9798	#[pallet::storage]99	#[pallet::getter(fn token_properties)]100	pub type TokenProperties<T: Config> = StorageNMap<101		Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),102		Value = Properties,103		QueryKind = ValueQuery,104		OnEmpty = up_data_structs::TokenProperties,105	>;106107	/// Used to enumerate tokens owned by account108	#[pallet::storage]109	pub type Owned<T: Config> = StorageNMap<110		Key = (111			Key<Twox64Concat, CollectionId>,112			Key<Blake2_128Concat, T::CrossAccountId>,113			Key<Twox64Concat, TokenId>,114		),115		Value = bool,116		QueryKind = ValueQuery,117	>;118119	#[pallet::storage]120	pub type AccountBalance<T: Config> = StorageNMap<121		Key = (122			Key<Twox64Concat, CollectionId>,123			Key<Blake2_128Concat, T::CrossAccountId>,124		),125		Value = u32,126		QueryKind = ValueQuery,127	>;128129	#[pallet::storage]130	pub type Allowance<T: Config> = StorageNMap<131		Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),132		Value = T::CrossAccountId,133		QueryKind = OptionQuery,134	>;135}136137pub struct NonfungibleHandle<T: Config>(pallet_common::CollectionHandle<T>);138impl<T: Config> NonfungibleHandle<T> {139	pub fn cast(inner: pallet_common::CollectionHandle<T>) -> Self {140		Self(inner)141	}142	pub fn into_inner(self) -> pallet_common::CollectionHandle<T> {143		self.0144	}145	pub fn common_mut(&mut self) -> &mut pallet_common::CollectionHandle<T> {146		&mut self.0147	}148}149impl<T: Config> WithRecorder<T> for NonfungibleHandle<T> {150	fn recorder(&self) -> &SubstrateRecorder<T> {151		self.0.recorder()152	}153	fn into_recorder(self) -> SubstrateRecorder<T> {154		self.0.into_recorder()155	}156}157impl<T: Config> Deref for NonfungibleHandle<T> {158	type Target = pallet_common::CollectionHandle<T>;159160	fn deref(&self) -> &Self::Target {161		&self.0162	}163}164165impl<T: Config> Pallet<T> {166	pub fn total_supply(collection: &NonfungibleHandle<T>) -> u32 {167		<TokensMinted<T>>::get(collection.id) - <TokensBurnt<T>>::get(collection.id)168	}169	pub fn token_exists(collection: &NonfungibleHandle<T>, token: TokenId) -> bool {170		<TokenData<T>>::contains_key((collection.id, token))171	}172}173174// unchecked calls skips any permission checks175impl<T: Config> Pallet<T> {176	pub fn init_collection(177		owner: T::AccountId,178		data: CreateCollectionData<T::AccountId>,179	) -> Result<CollectionId, DispatchError> {180		<PalletCommon<T>>::init_collection(owner, data)181	}182	pub fn destroy_collection(183		collection: NonfungibleHandle<T>,184		sender: &T::CrossAccountId,185	) -> DispatchResult {186		let id = collection.id;187188		// =========189190		PalletCommon::destroy_collection(collection.0, sender)?;191192		<TokenData<T>>::remove_prefix((id,), None);193		<Owned<T>>::remove_prefix((id,), None);194		<TokensMinted<T>>::remove(id);195		<TokensBurnt<T>>::remove(id);196		<Allowance<T>>::remove_prefix((id,), None);197		<AccountBalance<T>>::remove_prefix((id,), None);198		Ok(())199	}200201	pub fn burn(202		collection: &NonfungibleHandle<T>,203		sender: &T::CrossAccountId,204		token: TokenId,205	) -> DispatchResult {206		let token_data =207			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;208		ensure!(209			&token_data.owner == sender210				|| (collection.limits.owner_can_transfer() && collection.is_owner_or_admin(sender)),211			<CommonError<T>>::NoPermission212		);213214		if collection.access == AccessMode::AllowList {215			collection.check_allowlist(sender)?;216		}217218		let burnt = <TokensBurnt<T>>::get(collection.id)219			.checked_add(1)220			.ok_or(ArithmeticError::Overflow)?;221222		let balance = <AccountBalance<T>>::get((collection.id, token_data.owner.clone()))223			.checked_sub(1)224			.ok_or(ArithmeticError::Overflow)?;225226		if balance == 0 {227			<AccountBalance<T>>::remove((collection.id, token_data.owner.clone()));228		} else {229			<AccountBalance<T>>::insert((collection.id, token_data.owner.clone()), balance);230		}231		// =========232233		<Owned<T>>::remove((collection.id, &token_data.owner, token));234		<TokensBurnt<T>>::insert(collection.id, burnt);235		<TokenData<T>>::remove((collection.id, token));236		let old_spender = <Allowance<T>>::take((collection.id, token));237238		if let Some(old_spender) = old_spender {239			<PalletCommon<T>>::deposit_event(CommonEvent::Approved(240				collection.id,241				token,242				sender.clone(),243				old_spender,244				0,245			));246		}247248		collection.log_mirrored(ERC721Events::Transfer {249			from: *token_data.owner.as_eth(),250			to: H160::default(),251			token_id: token.into(),252		});253		<PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(254			collection.id,255			token,256			token_data.owner,257			1,258		));259		Ok(())260	}261262	pub fn set_token_property(263		collection: &NonfungibleHandle<T>,264		sender: &T::CrossAccountId,265		token_id: TokenId,266		property: Property,267	) -> DispatchResult {268		Self::check_token_change_permission(collection, sender, token_id, &property.key)?;269270		<TokenProperties<T>>::try_mutate((collection.id, token_id), |properties| {271			let property = property.clone();272			properties.try_set(property.key, property.value)273		})274		.map_err(<CommonError<T>>::from)?;275276		<PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertySet(277			collection.id,278			token_id,279			property.key,280		));281282		Ok(())283	}284285	pub fn set_token_properties(286		collection: &NonfungibleHandle<T>,287		sender: &T::CrossAccountId,288		token_id: TokenId,289		properties: Vec<Property>,290	) -> DispatchResult {291		for property in properties {292			Self::set_token_property(collection, sender, token_id, property)?;293		}294295		Ok(())296	}297298	pub fn delete_token_property(299		collection: &NonfungibleHandle<T>,300		sender: &T::CrossAccountId,301		token_id: TokenId,302		property_key: PropertyKey,303	) -> DispatchResult {304		Self::check_token_change_permission(collection, sender, token_id, &property_key)?;305306		<TokenProperties<T>>::try_mutate((collection.id, token_id), |properties| {307			properties.remove(&property_key)308		})309		.map_err(<CommonError<T>>::from)?;310311		<PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertyDeleted(312			collection.id,313			token_id,314			property_key,315		));316317		Ok(())318	}319320	fn check_token_change_permission(321		collection: &NonfungibleHandle<T>,322		sender: &T::CrossAccountId,323		token_id: TokenId,324		property_key: &PropertyKey,325	) -> DispatchResult {326		let permission = <PalletCommon<T>>::property_permissions(collection.id)327			.get(property_key)328			.map(|p| p.clone())329			.unwrap_or(PropertyPermission::none());330331		let token_data = <TokenData<T>>::get((collection.id, token_id))332			.ok_or(<CommonError<T>>::TokenNotFound)?;333334		let check_token_owner = || -> DispatchResult {335			ensure!(&token_data.owner == sender, <CommonError<T>>::NoPermission);336			Ok(())337		};338339		let is_property_exists = TokenProperties::<T>::get((collection.id, token_id))340			.get(property_key)341			.is_some();342343		match permission {344			PropertyPermission { mutable: false, .. } if is_property_exists => {345				Err(<CommonError<T>>::NoPermission.into())346			}347348			PropertyPermission {349				collection_admin,350				token_owner,351				..352			} => {353				let mut check_result = Err(<CommonError<T>>::NoPermission.into());354355				if collection_admin {356					check_result = collection.check_is_owner_or_admin(sender);357				}358359				if token_owner {360					check_result.or(check_token_owner())361				} else {362					check_result363				}364			}365		}366	}367368	pub fn delete_token_properties(369		collection: &NonfungibleHandle<T>,370		sender: &T::CrossAccountId,371		token_id: TokenId,372		property_keys: Vec<PropertyKey>,373	) -> DispatchResult {374		for key in property_keys {375			Self::delete_token_property(collection, sender, token_id, key)?;376		}377378		Ok(())379	}380381	pub fn set_collection_properties(382		collection: &NonfungibleHandle<T>,383		sender: &T::CrossAccountId,384		properties: Vec<Property>,385	) -> DispatchResult {386		<PalletCommon<T>>::set_collection_properties(collection, sender, properties)387	}388389	pub fn delete_collection_properties(390		collection: &CollectionHandle<T>,391		sender: &T::CrossAccountId,392		property_keys: Vec<PropertyKey>,393	) -> DispatchResult {394		<PalletCommon<T>>::delete_collection_properties(collection, sender, property_keys)395	}396397	pub fn set_property_permissions(398		collection: &CollectionHandle<T>,399		sender: &T::CrossAccountId,400		property_permissions: Vec<PropertyKeyPermission>,401	) -> DispatchResult {402		<PalletCommon<T>>::set_property_permissions(collection, sender, property_permissions)403	}404405	pub fn transfer(406		collection: &NonfungibleHandle<T>,407		from: &T::CrossAccountId,408		to: &T::CrossAccountId,409		token: TokenId,410		nesting_budget: &dyn Budget,411	) -> DispatchResult {412		ensure!(413			collection.limits.transfers_enabled(),414			<CommonError<T>>::TransferNotAllowed415		);416417		let token_data =418			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;419		// TODO: require sender to be token, owner, require admins to go through transfer_from420		ensure!(421			&token_data.owner == from422				|| (collection.limits.owner_can_transfer() && collection.is_owner_or_admin(from)),423			<CommonError<T>>::NoPermission424		);425426		if collection.access == AccessMode::AllowList {427			collection.check_allowlist(from)?;428			collection.check_allowlist(to)?;429		}430		<PalletCommon<T>>::ensure_correct_receiver(to)?;431432		let balance_from = <AccountBalance<T>>::get((collection.id, from))433			.checked_sub(1)434			.ok_or(<CommonError<T>>::TokenValueTooLow)?;435		let balance_to = if from != to {436			let balance_to = <AccountBalance<T>>::get((collection.id, to))437				.checked_add(1)438				.ok_or(ArithmeticError::Overflow)?;439440			ensure!(441				balance_to < collection.limits.account_token_ownership_limit(),442				<CommonError<T>>::AccountTokenLimitExceeded,443			);444445			Some(balance_to)446		} else {447			None448		};449450		if let Some(target) = T::CrossTokenAddressMapping::address_to_token(to) {451			let handle = <CollectionHandle<T>>::try_get(target.0)?;452			let dispatch = T::CollectionDispatch::dispatch(handle);453			let dispatch = dispatch.as_dyn();454455			dispatch.check_nesting(456				from.clone(),457				(collection.id, token),458				target.1,459				nesting_budget,460			)?;461		}462463		// =========464465		<TokenData<T>>::insert(466			(collection.id, token),467			ItemData {468				owner: to.clone(),469				..token_data470			},471		);472473		if let Some(balance_to) = balance_to {474			// from != to475			if balance_from == 0 {476				<AccountBalance<T>>::remove((collection.id, from));477			} else {478				<AccountBalance<T>>::insert((collection.id, from), balance_from);479			}480			<AccountBalance<T>>::insert((collection.id, to), balance_to);481			<Owned<T>>::remove((collection.id, from, token));482			<Owned<T>>::insert((collection.id, to, token), true);483		}484		Self::set_allowance_unchecked(collection, from, token, None, true);485486		collection.log_mirrored(ERC721Events::Transfer {487			from: *from.as_eth(),488			to: *to.as_eth(),489			token_id: token.into(),490		});491		<PalletCommon<T>>::deposit_event(CommonEvent::Transfer(492			collection.id,493			token,494			from.clone(),495			to.clone(),496			1,497		));498		Ok(())499	}500501	pub fn create_multiple_items(502		collection: &NonfungibleHandle<T>,503		sender: &T::CrossAccountId,504		data: Vec<CreateItemData<T>>,505		nesting_budget: &dyn Budget,506	) -> DispatchResult {507		if !collection.is_owner_or_admin(sender) {508			ensure!(509				collection.mint_mode,510				<CommonError<T>>::PublicMintingNotAllowed511			);512			collection.check_allowlist(sender)?;513514			for item in data.iter() {515				collection.check_allowlist(&item.owner)?;516			}517		}518519		for data in data.iter() {520			<PalletCommon<T>>::ensure_correct_receiver(&data.owner)?;521		}522523		let first_token = <TokensMinted<T>>::get(collection.id);524		let tokens_minted = first_token525			.checked_add(data.len() as u32)526			.ok_or(ArithmeticError::Overflow)?;527		ensure!(528			tokens_minted <= collection.limits.token_limit(),529			<CommonError<T>>::CollectionTokenLimitExceeded530		);531532		let mut balances = BTreeMap::new();533		for data in &data {534			let balance = balances535				.entry(&data.owner)536				.or_insert_with(|| <AccountBalance<T>>::get((collection.id, &data.owner)));537			*balance = balance.checked_add(1).ok_or(ArithmeticError::Overflow)?;538539			ensure!(540				*balance <= collection.limits.account_token_ownership_limit(),541				<CommonError<T>>::AccountTokenLimitExceeded,542			);543		}544545		for (i, data) in data.iter().enumerate() {546			let token = TokenId(first_token + i as u32 + 1);547			if let Some(target) = T::CrossTokenAddressMapping::address_to_token(&data.owner) {548				let handle = <CollectionHandle<T>>::try_get(target.0)?;549				let dispatch = T::CollectionDispatch::dispatch(handle);550				let dispatch = dispatch.as_dyn();551				dispatch.check_nesting(552					sender.clone(),553					(collection.id, token),554					target.1,555					nesting_budget,556				)?;557			}558		}559560		// =========561562		<TokensMinted<T>>::insert(collection.id, tokens_minted);563		for (account, balance) in balances {564			<AccountBalance<T>>::insert((collection.id, account), balance);565		}566		for (i, data) in data.into_iter().enumerate() {567			let token = first_token + i as u32 + 1;568569			<TokenData<T>>::insert(570				(collection.id, token),571				ItemData {572					const_data: data.const_data,573					variable_data: data.variable_data,574					owner: data.owner.clone(),575				},576			);577			<Owned<T>>::insert((collection.id, &data.owner, token), true);578579			Self::set_token_properties(580				collection,581				sender,582				TokenId(token),583				data.properties.into_inner(),584			)?;585586			collection.log_mirrored(ERC721Events::Transfer {587				from: H160::default(),588				to: *data.owner.as_eth(),589				token_id: token.into(),590			});591			<PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(592				collection.id,593				TokenId(token),594				data.owner.clone(),595				1,596			));597		}598		Ok(())599	}600601	pub fn set_allowance_unchecked(602		collection: &NonfungibleHandle<T>,603		sender: &T::CrossAccountId,604		token: TokenId,605		spender: Option<&T::CrossAccountId>,606		assume_implicit_eth: bool,607	) {608		if let Some(spender) = spender {609			let old_spender = <Allowance<T>>::get((collection.id, token));610			<Allowance<T>>::insert((collection.id, token), spender);611			// In ERC721 there is only one possible approved user of token, so we set612			// approved user to spender613			collection.log_mirrored(ERC721Events::Approval {614				owner: *sender.as_eth(),615				approved: *spender.as_eth(),616				token_id: token.into(),617			});618			// In Unique chain, any token can have any amount of approved users, so we need to619			// set allowance of old owner to 0, and allowance of new owner to 1620			if old_spender.as_ref() != Some(spender) {621				if let Some(old_owner) = old_spender {622					<PalletCommon<T>>::deposit_event(CommonEvent::Approved(623						collection.id,624						token,625						sender.clone(),626						old_owner,627						0,628					));629				}630				<PalletCommon<T>>::deposit_event(CommonEvent::Approved(631					collection.id,632					token,633					sender.clone(),634					spender.clone(),635					1,636				));637			}638		} else {639			let old_spender = <Allowance<T>>::take((collection.id, token));640			if !assume_implicit_eth {641				// In ERC721 there is only one possible approved user of token, so we set642				// approved user to zero address643				collection.log_mirrored(ERC721Events::Approval {644					owner: *sender.as_eth(),645					approved: H160::default(),646					token_id: token.into(),647				});648			}649			// In Unique chain, any token can have any amount of approved users, so we need to650			// set allowance of old owner to 0651			if let Some(old_spender) = old_spender {652				<PalletCommon<T>>::deposit_event(CommonEvent::Approved(653					collection.id,654					token,655					sender.clone(),656					old_spender,657					0,658				));659			}660		}661	}662663	pub fn set_allowance(664		collection: &NonfungibleHandle<T>,665		sender: &T::CrossAccountId,666		token: TokenId,667		spender: Option<&T::CrossAccountId>,668	) -> DispatchResult {669		if collection.access == AccessMode::AllowList {670			collection.check_allowlist(sender)?;671			if let Some(spender) = spender {672				collection.check_allowlist(spender)?;673			}674		}675676		if let Some(spender) = spender {677			<PalletCommon<T>>::ensure_correct_receiver(spender)?;678		}679		let token_data =680			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;681		if &token_data.owner != sender {682			ensure!(683				collection.ignores_owned_amount(sender),684				<CommonError<T>>::CantApproveMoreThanOwned685			);686		}687688		// =========689690		Self::set_allowance_unchecked(collection, sender, token, spender, false);691		Ok(())692	}693694	fn check_allowed(695		collection: &NonfungibleHandle<T>,696		spender: &T::CrossAccountId,697		from: &T::CrossAccountId,698		token: TokenId,699		nesting_budget: &dyn Budget,700	) -> DispatchResult {701		if spender.conv_eq(from) {702			return Ok(());703		}704		if collection.access == AccessMode::AllowList {705			// `from`, `to` checked in [`transfer`]706			collection.check_allowlist(spender)?;707		}708		if let Some(source) = T::CrossTokenAddressMapping::address_to_token(from) {709			// TODO: should collection owner be allowed to perform this transfer?710			ensure!(711				<PalletStructure<T>>::check_indirectly_owned(712					spender.clone(),713					source.0,714					source.1,715					None,716					nesting_budget717				)?,718				<CommonError<T>>::ApprovedValueTooLow,719			);720			return Ok(());721		}722		if <Allowance<T>>::get((collection.id, token)).as_ref() == Some(spender) {723			return Ok(());724		}725		ensure!(726			collection.ignores_allowance(spender),727			<CommonError<T>>::ApprovedValueTooLow728		);729		Ok(())730	}731732	pub fn transfer_from(733		collection: &NonfungibleHandle<T>,734		spender: &T::CrossAccountId,735		from: &T::CrossAccountId,736		to: &T::CrossAccountId,737		token: TokenId,738		nesting_budget: &dyn Budget,739	) -> DispatchResult {740		Self::check_allowed(collection, spender, from, token, nesting_budget)?;741742		// =========743744		// Allowance is reset in [`transfer`]745		Self::transfer(collection, from, to, token, nesting_budget)746	}747748	pub fn burn_from(749		collection: &NonfungibleHandle<T>,750		spender: &T::CrossAccountId,751		from: &T::CrossAccountId,752		token: TokenId,753		nesting_budget: &dyn Budget,754	) -> DispatchResult {755		Self::check_allowed(collection, spender, from, token, nesting_budget)?;756757		// =========758759		Self::burn(collection, from, token)760	}761762	pub fn set_variable_metadata(763		collection: &NonfungibleHandle<T>,764		sender: &T::CrossAccountId,765		token: TokenId,766		data: BoundedVec<u8, CustomDataLimit>,767	) -> DispatchResult {768		let token_data =769			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;770		collection.check_can_update_meta(sender, &token_data.owner)?;771772		// =========773774		<TokenData<T>>::insert(775			(collection.id, token),776			ItemData {777				variable_data: data,778				..token_data779			},780		);781		Ok(())782	}783784	pub fn check_nesting(785		handle: &NonfungibleHandle<T>,786		sender: T::CrossAccountId,787		from: (CollectionId, TokenId),788		under: TokenId,789		nesting_budget: &dyn Budget,790	) -> DispatchResult {791		fn ensure_sender_allowed<T: Config>(792			collection: CollectionId,793			token: TokenId,794			for_nest: (CollectionId, TokenId),795			sender: T::CrossAccountId,796			budget: &dyn Budget,797		) -> DispatchResult {798			ensure!(799				<PalletStructure<T>>::check_indirectly_owned(800					sender,801					collection,802					token,803					Some(for_nest),804					budget805				)?,806				<CommonError<T>>::OnlyOwnerAllowedToNest,807			);808			Ok(())809		}810		match handle.limits.nesting_rule() {811			NestingRule::Disabled => fail!(<CommonError<T>>::NestingIsDisabled),812			NestingRule::Owner => {813				ensure_sender_allowed::<T>(handle.id, under, from, sender, nesting_budget)?814			}815			NestingRule::OwnerRestricted(whitelist) => {816				ensure!(817					whitelist.contains(&from.0),818					<CommonError<T>>::SourceCollectionIsNotAllowedToNest819				);820				ensure_sender_allowed::<T>(handle.id, under, from, sender, nesting_budget)?821			}822		}823		Ok(())824	}825826	/// Delegated to `create_multiple_items`827	pub fn create_item(828		collection: &NonfungibleHandle<T>,829		sender: &T::CrossAccountId,830		data: CreateItemData<T>,831		nesting_budget: &dyn Budget,832	) -> DispatchResult {833		Self::create_multiple_items(collection, sender, vec![data], nesting_budget)834	}835}
after · pallets/nonfungible/src/lib.rs
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/>.1617#![cfg_attr(not(feature = "std"), no_std)]1819use erc::ERC721Events;20use evm_coder::ToLog;21use frame_support::{BoundedVec, ensure, fail};22use up_data_structs::{23	AccessMode, CollectionId, CustomDataLimit, TokenId, CreateCollectionData, CreateNftExData,24	mapping::TokenAddressMapping, NestingRule, budget::Budget, Property, PropertyPermission,25	PropertyKey, PropertyKeyPermission, Properties, TrySet,26};27use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};28use pallet_common::{29	Error as CommonError, Pallet as PalletCommon, Event as CommonEvent, CollectionHandle,30	dispatch::CollectionDispatch, eth::collection_id_to_address,31};32use pallet_structure::Pallet as PalletStructure;33use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};34use sp_core::H160;35use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};36use sp_std::{vec::Vec, vec};37use core::ops::Deref;38use sp_std::collections::btree_map::BTreeMap;39use codec::{Encode, Decode, MaxEncodedLen};40use scale_info::TypeInfo;4142pub use pallet::*;43#[cfg(feature = "runtime-benchmarks")]44pub mod benchmarking;45pub mod common;46pub mod erc;47pub mod weights;4849pub type CreateItemData<T> = CreateNftExData<<T as pallet_evm::account::Config>::CrossAccountId>;50pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;5152#[derive(Encode, Decode, TypeInfo, MaxEncodedLen)]53pub struct ItemData<CrossAccountId> {54	pub const_data: BoundedVec<u8, CustomDataLimit>,55	pub variable_data: BoundedVec<u8, CustomDataLimit>,56	pub owner: CrossAccountId,57}5859#[frame_support::pallet]60pub mod pallet {61	use super::*;62	use frame_support::{Blake2_128Concat, Twox64Concat, pallet_prelude::*, storage::Key};63	use up_data_structs::{CollectionId, TokenId};64	use super::weights::WeightInfo;6566	#[pallet::error]67	pub enum Error<T> {68		/// Not Nonfungible item data used to mint in Nonfungible collection.69		NotNonfungibleDataUsedToMintFungibleCollectionToken,70		/// Used amount > 1 with NFT71		NonfungibleItemsHaveNoAmount,72	}7374	#[pallet::config]75	pub trait Config:76		frame_system::Config + pallet_common::Config + pallet_structure::Config + pallet_evm::Config77	{78		type WeightInfo: WeightInfo;79	}8081	#[pallet::pallet]82	#[pallet::generate_store(pub(super) trait Store)]83	pub struct Pallet<T>(_);8485	#[pallet::storage]86	pub type TokensMinted<T: Config> =87		StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;88	#[pallet::storage]89	pub type TokensBurnt<T: Config> =90		StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;9192	#[pallet::storage]93	pub type TokenData<T: Config> = StorageNMap<94		Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),95		Value = ItemData<T::CrossAccountId>,96		QueryKind = OptionQuery,97	>;9899	#[pallet::storage]100	#[pallet::getter(fn token_properties)]101	pub type TokenProperties<T: Config> = StorageNMap<102		Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),103		Value = Properties,104		QueryKind = ValueQuery,105		OnEmpty = up_data_structs::TokenProperties,106	>;107108	/// Used to enumerate tokens owned by account109	#[pallet::storage]110	pub type Owned<T: Config> = StorageNMap<111		Key = (112			Key<Twox64Concat, CollectionId>,113			Key<Blake2_128Concat, T::CrossAccountId>,114			Key<Twox64Concat, TokenId>,115		),116		Value = bool,117		QueryKind = ValueQuery,118	>;119120	#[pallet::storage]121	pub type AccountBalance<T: Config> = StorageNMap<122		Key = (123			Key<Twox64Concat, CollectionId>,124			Key<Blake2_128Concat, T::CrossAccountId>,125		),126		Value = u32,127		QueryKind = ValueQuery,128	>;129130	#[pallet::storage]131	pub type Allowance<T: Config> = StorageNMap<132		Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),133		Value = T::CrossAccountId,134		QueryKind = OptionQuery,135	>;136}137138pub struct NonfungibleHandle<T: Config>(pallet_common::CollectionHandle<T>);139impl<T: Config> NonfungibleHandle<T> {140	pub fn cast(inner: pallet_common::CollectionHandle<T>) -> Self {141		Self(inner)142	}143	pub fn into_inner(self) -> pallet_common::CollectionHandle<T> {144		self.0145	}146	pub fn common_mut(&mut self) -> &mut pallet_common::CollectionHandle<T> {147		&mut self.0148	}149}150impl<T: Config> WithRecorder<T> for NonfungibleHandle<T> {151	fn recorder(&self) -> &SubstrateRecorder<T> {152		self.0.recorder()153	}154	fn into_recorder(self) -> SubstrateRecorder<T> {155		self.0.into_recorder()156	}157}158impl<T: Config> Deref for NonfungibleHandle<T> {159	type Target = pallet_common::CollectionHandle<T>;160161	fn deref(&self) -> &Self::Target {162		&self.0163	}164}165166impl<T: Config> Pallet<T> {167	pub fn total_supply(collection: &NonfungibleHandle<T>) -> u32 {168		<TokensMinted<T>>::get(collection.id) - <TokensBurnt<T>>::get(collection.id)169	}170	pub fn token_exists(collection: &NonfungibleHandle<T>, token: TokenId) -> bool {171		<TokenData<T>>::contains_key((collection.id, token))172	}173}174175// unchecked calls skips any permission checks176impl<T: Config> Pallet<T> {177	pub fn init_collection(178		owner: T::AccountId,179		data: CreateCollectionData<T::AccountId>,180	) -> Result<CollectionId, DispatchError> {181		<PalletCommon<T>>::init_collection(owner, data)182	}183	pub fn destroy_collection(184		collection: NonfungibleHandle<T>,185		sender: &T::CrossAccountId,186	) -> DispatchResult {187		let id = collection.id;188189		// =========190191		PalletCommon::destroy_collection(collection.0, sender)?;192193		<TokenData<T>>::remove_prefix((id,), None);194		<Owned<T>>::remove_prefix((id,), None);195		<TokensMinted<T>>::remove(id);196		<TokensBurnt<T>>::remove(id);197		<Allowance<T>>::remove_prefix((id,), None);198		<AccountBalance<T>>::remove_prefix((id,), None);199		Ok(())200	}201202	pub fn burn(203		collection: &NonfungibleHandle<T>,204		sender: &T::CrossAccountId,205		token: TokenId,206	) -> DispatchResult {207		let token_data =208			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;209		ensure!(210			&token_data.owner == sender211				|| (collection.limits.owner_can_transfer() && collection.is_owner_or_admin(sender)),212			<CommonError<T>>::NoPermission213		);214215		if collection.access == AccessMode::AllowList {216			collection.check_allowlist(sender)?;217		}218219		let burnt = <TokensBurnt<T>>::get(collection.id)220			.checked_add(1)221			.ok_or(ArithmeticError::Overflow)?;222223		let balance = <AccountBalance<T>>::get((collection.id, token_data.owner.clone()))224			.checked_sub(1)225			.ok_or(ArithmeticError::Overflow)?;226227		if balance == 0 {228			<AccountBalance<T>>::remove((collection.id, token_data.owner.clone()));229		} else {230			<AccountBalance<T>>::insert((collection.id, token_data.owner.clone()), balance);231		}232		// =========233234		<Owned<T>>::remove((collection.id, &token_data.owner, token));235		<TokensBurnt<T>>::insert(collection.id, burnt);236		<TokenData<T>>::remove((collection.id, token));237		let old_spender = <Allowance<T>>::take((collection.id, token));238239		if let Some(old_spender) = old_spender {240			<PalletCommon<T>>::deposit_event(CommonEvent::Approved(241				collection.id,242				token,243				sender.clone(),244				old_spender,245				0,246			));247		}248249		<PalletEvm<T>>::deposit_log(250			ERC721Events::Transfer {251				from: *token_data.owner.as_eth(),252				to: H160::default(),253				token_id: token.into(),254			}255			.to_log(collection_id_to_address(collection.id)),256		);257		<PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(258			collection.id,259			token,260			token_data.owner,261			1,262		));263		Ok(())264	}265266	pub fn set_token_property(267		collection: &NonfungibleHandle<T>,268		sender: &T::CrossAccountId,269		token_id: TokenId,270		property: Property,271	) -> DispatchResult {272		Self::check_token_change_permission(collection, sender, token_id, &property.key)?;273274		<TokenProperties<T>>::try_mutate((collection.id, token_id), |properties| {275			let property = property.clone();276			properties.try_set(property.key, property.value)277		})278		.map_err(<CommonError<T>>::from)?;279280		<PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertySet(281			collection.id,282			token_id,283			property.key,284		));285286		Ok(())287	}288289	pub fn set_token_properties(290		collection: &NonfungibleHandle<T>,291		sender: &T::CrossAccountId,292		token_id: TokenId,293		properties: Vec<Property>,294	) -> DispatchResult {295		for property in properties {296			Self::set_token_property(collection, sender, token_id, property)?;297		}298299		Ok(())300	}301302	pub fn delete_token_property(303		collection: &NonfungibleHandle<T>,304		sender: &T::CrossAccountId,305		token_id: TokenId,306		property_key: PropertyKey,307	) -> DispatchResult {308		Self::check_token_change_permission(collection, sender, token_id, &property_key)?;309310		<TokenProperties<T>>::try_mutate((collection.id, token_id), |properties| {311			properties.remove(&property_key)312		})313		.map_err(<CommonError<T>>::from)?;314315		<PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertyDeleted(316			collection.id,317			token_id,318			property_key,319		));320321		Ok(())322	}323324	fn check_token_change_permission(325		collection: &NonfungibleHandle<T>,326		sender: &T::CrossAccountId,327		token_id: TokenId,328		property_key: &PropertyKey,329	) -> DispatchResult {330		let permission = <PalletCommon<T>>::property_permissions(collection.id)331			.get(property_key)332			.map(|p| p.clone())333			.unwrap_or(PropertyPermission::none());334335		let token_data = <TokenData<T>>::get((collection.id, token_id))336			.ok_or(<CommonError<T>>::TokenNotFound)?;337338		let check_token_owner = || -> DispatchResult {339			ensure!(&token_data.owner == sender, <CommonError<T>>::NoPermission);340			Ok(())341		};342343		let is_property_exists = TokenProperties::<T>::get((collection.id, token_id))344			.get(property_key)345			.is_some();346347		match permission {348			PropertyPermission { mutable: false, .. } if is_property_exists => {349				Err(<CommonError<T>>::NoPermission.into())350			}351352			PropertyPermission {353				collection_admin,354				token_owner,355				..356			} => {357				let mut check_result = Err(<CommonError<T>>::NoPermission.into());358359				if collection_admin {360					check_result = collection.check_is_owner_or_admin(sender);361				}362363				if token_owner {364					check_result.and_then(|()| check_token_owner())365				} else {366					check_result367				}368			}369		}370	}371372	pub fn delete_token_properties(373		collection: &NonfungibleHandle<T>,374		sender: &T::CrossAccountId,375		token_id: TokenId,376		property_keys: Vec<PropertyKey>,377	) -> DispatchResult {378		for key in property_keys {379			Self::delete_token_property(collection, sender, token_id, key)?;380		}381382		Ok(())383	}384385	pub fn set_collection_properties(386		collection: &NonfungibleHandle<T>,387		sender: &T::CrossAccountId,388		properties: Vec<Property>,389	) -> DispatchResult {390		<PalletCommon<T>>::set_collection_properties(collection, sender, properties)391	}392393	pub fn delete_collection_properties(394		collection: &CollectionHandle<T>,395		sender: &T::CrossAccountId,396		property_keys: Vec<PropertyKey>,397	) -> DispatchResult {398		<PalletCommon<T>>::delete_collection_properties(collection, sender, property_keys)399	}400401	pub fn set_property_permissions(402		collection: &CollectionHandle<T>,403		sender: &T::CrossAccountId,404		property_permissions: Vec<PropertyKeyPermission>,405	) -> DispatchResult {406		<PalletCommon<T>>::set_property_permissions(collection, sender, property_permissions)407	}408409	pub fn transfer(410		collection: &NonfungibleHandle<T>,411		from: &T::CrossAccountId,412		to: &T::CrossAccountId,413		token: TokenId,414		nesting_budget: &dyn Budget,415	) -> DispatchResult {416		ensure!(417			collection.limits.transfers_enabled(),418			<CommonError<T>>::TransferNotAllowed419		);420421		let token_data =422			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;423		// TODO: require sender to be token, owner, require admins to go through transfer_from424		ensure!(425			&token_data.owner == from426				|| (collection.limits.owner_can_transfer() && collection.is_owner_or_admin(from)),427			<CommonError<T>>::NoPermission428		);429430		if collection.access == AccessMode::AllowList {431			collection.check_allowlist(from)?;432			collection.check_allowlist(to)?;433		}434		<PalletCommon<T>>::ensure_correct_receiver(to)?;435436		let balance_from = <AccountBalance<T>>::get((collection.id, from))437			.checked_sub(1)438			.ok_or(<CommonError<T>>::TokenValueTooLow)?;439		let balance_to = if from != to {440			let balance_to = <AccountBalance<T>>::get((collection.id, to))441				.checked_add(1)442				.ok_or(ArithmeticError::Overflow)?;443444			ensure!(445				balance_to < collection.limits.account_token_ownership_limit(),446				<CommonError<T>>::AccountTokenLimitExceeded,447			);448449			Some(balance_to)450		} else {451			None452		};453454		if let Some(target) = T::CrossTokenAddressMapping::address_to_token(to) {455			let handle = <CollectionHandle<T>>::try_get(target.0)?;456			let dispatch = T::CollectionDispatch::dispatch(handle);457			let dispatch = dispatch.as_dyn();458459			dispatch.check_nesting(460				from.clone(),461				(collection.id, token),462				target.1,463				nesting_budget,464			)?;465		}466467		// =========468469		<TokenData<T>>::insert(470			(collection.id, token),471			ItemData {472				owner: to.clone(),473				..token_data474			},475		);476477		if let Some(balance_to) = balance_to {478			// from != to479			if balance_from == 0 {480				<AccountBalance<T>>::remove((collection.id, from));481			} else {482				<AccountBalance<T>>::insert((collection.id, from), balance_from);483			}484			<AccountBalance<T>>::insert((collection.id, to), balance_to);485			<Owned<T>>::remove((collection.id, from, token));486			<Owned<T>>::insert((collection.id, to, token), true);487		}488		Self::set_allowance_unchecked(collection, from, token, None, true);489490		<PalletEvm<T>>::deposit_log(491			ERC721Events::Transfer {492				from: *from.as_eth(),493				to: *to.as_eth(),494				token_id: token.into(),495			}496			.to_log(collection_id_to_address(collection.id)),497		);498		<PalletCommon<T>>::deposit_event(CommonEvent::Transfer(499			collection.id,500			token,501			from.clone(),502			to.clone(),503			1,504		));505		Ok(())506	}507508	pub fn create_multiple_items(509		collection: &NonfungibleHandle<T>,510		sender: &T::CrossAccountId,511		data: Vec<CreateItemData<T>>,512		nesting_budget: &dyn Budget,513	) -> DispatchResult {514		if !collection.is_owner_or_admin(sender) {515			ensure!(516				collection.mint_mode,517				<CommonError<T>>::PublicMintingNotAllowed518			);519			collection.check_allowlist(sender)?;520521			for item in data.iter() {522				collection.check_allowlist(&item.owner)?;523			}524		}525526		for data in data.iter() {527			<PalletCommon<T>>::ensure_correct_receiver(&data.owner)?;528		}529530		let first_token = <TokensMinted<T>>::get(collection.id);531		let tokens_minted = first_token532			.checked_add(data.len() as u32)533			.ok_or(ArithmeticError::Overflow)?;534		ensure!(535			tokens_minted <= collection.limits.token_limit(),536			<CommonError<T>>::CollectionTokenLimitExceeded537		);538539		let mut balances = BTreeMap::new();540		for data in &data {541			let balance = balances542				.entry(&data.owner)543				.or_insert_with(|| <AccountBalance<T>>::get((collection.id, &data.owner)));544			*balance = balance.checked_add(1).ok_or(ArithmeticError::Overflow)?;545546			ensure!(547				*balance <= collection.limits.account_token_ownership_limit(),548				<CommonError<T>>::AccountTokenLimitExceeded,549			);550		}551552		for (i, data) in data.iter().enumerate() {553			let token = TokenId(first_token + i as u32 + 1);554			if let Some(target) = T::CrossTokenAddressMapping::address_to_token(&data.owner) {555				let handle = <CollectionHandle<T>>::try_get(target.0)?;556				let dispatch = T::CollectionDispatch::dispatch(handle);557				let dispatch = dispatch.as_dyn();558				dispatch.check_nesting(559					sender.clone(),560					(collection.id, token),561					target.1,562					nesting_budget,563				)?;564			}565		}566567		// =========568569		<TokensMinted<T>>::insert(collection.id, tokens_minted);570		for (account, balance) in balances {571			<AccountBalance<T>>::insert((collection.id, account), balance);572		}573		for (i, data) in data.into_iter().enumerate() {574			let token = first_token + i as u32 + 1;575576			<TokenData<T>>::insert(577				(collection.id, token),578				ItemData {579					const_data: data.const_data,580					variable_data: data.variable_data,581					owner: data.owner.clone(),582				},583			);584			<Owned<T>>::insert((collection.id, &data.owner, token), true);585586			Self::set_token_properties(587				collection,588				sender,589				TokenId(token),590				data.properties.into_inner(),591			)?;592593			<PalletEvm<T>>::deposit_log(594				ERC721Events::Transfer {595					from: H160::default(),596					to: *data.owner.as_eth(),597					token_id: token.into(),598				}599				.to_log(collection_id_to_address(collection.id)),600			);601			<PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(602				collection.id,603				TokenId(token),604				data.owner.clone(),605				1,606			));607		}608		Ok(())609	}610611	pub fn set_allowance_unchecked(612		collection: &NonfungibleHandle<T>,613		sender: &T::CrossAccountId,614		token: TokenId,615		spender: Option<&T::CrossAccountId>,616		assume_implicit_eth: bool,617	) {618		if let Some(spender) = spender {619			let old_spender = <Allowance<T>>::get((collection.id, token));620			<Allowance<T>>::insert((collection.id, token), spender);621			// In ERC721 there is only one possible approved user of token, so we set622			// approved user to spender623			<PalletEvm<T>>::deposit_log(624				ERC721Events::Approval {625					owner: *sender.as_eth(),626					approved: *spender.as_eth(),627					token_id: token.into(),628				}629				.to_log(collection_id_to_address(collection.id)),630			);631			// In Unique chain, any token can have any amount of approved users, so we need to632			// set allowance of old owner to 0, and allowance of new owner to 1633			if old_spender.as_ref() != Some(spender) {634				if let Some(old_owner) = old_spender {635					<PalletCommon<T>>::deposit_event(CommonEvent::Approved(636						collection.id,637						token,638						sender.clone(),639						old_owner,640						0,641					));642				}643				<PalletCommon<T>>::deposit_event(CommonEvent::Approved(644					collection.id,645					token,646					sender.clone(),647					spender.clone(),648					1,649				));650			}651		} else {652			let old_spender = <Allowance<T>>::take((collection.id, token));653			if !assume_implicit_eth {654				// In ERC721 there is only one possible approved user of token, so we set655				// approved user to zero address656				<PalletEvm<T>>::deposit_log(657					ERC721Events::Approval {658						owner: *sender.as_eth(),659						approved: H160::default(),660						token_id: token.into(),661					}662					.to_log(collection_id_to_address(collection.id)),663				);664			}665			// In Unique chain, any token can have any amount of approved users, so we need to666			// set allowance of old owner to 0667			if let Some(old_spender) = old_spender {668				<PalletCommon<T>>::deposit_event(CommonEvent::Approved(669					collection.id,670					token,671					sender.clone(),672					old_spender,673					0,674				));675			}676		}677	}678679	pub fn set_allowance(680		collection: &NonfungibleHandle<T>,681		sender: &T::CrossAccountId,682		token: TokenId,683		spender: Option<&T::CrossAccountId>,684	) -> DispatchResult {685		if collection.access == AccessMode::AllowList {686			collection.check_allowlist(sender)?;687			if let Some(spender) = spender {688				collection.check_allowlist(spender)?;689			}690		}691692		if let Some(spender) = spender {693			<PalletCommon<T>>::ensure_correct_receiver(spender)?;694		}695		let token_data =696			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;697		if &token_data.owner != sender {698			ensure!(699				collection.ignores_owned_amount(sender),700				<CommonError<T>>::CantApproveMoreThanOwned701			);702		}703704		// =========705706		Self::set_allowance_unchecked(collection, sender, token, spender, false);707		Ok(())708	}709710	fn check_allowed(711		collection: &NonfungibleHandle<T>,712		spender: &T::CrossAccountId,713		from: &T::CrossAccountId,714		token: TokenId,715		nesting_budget: &dyn Budget,716	) -> DispatchResult {717		if spender.conv_eq(from) {718			return Ok(());719		}720		if collection.access == AccessMode::AllowList {721			// `from`, `to` checked in [`transfer`]722			collection.check_allowlist(spender)?;723		}724		if let Some(source) = T::CrossTokenAddressMapping::address_to_token(from) {725			// TODO: should collection owner be allowed to perform this transfer?726			ensure!(727				<PalletStructure<T>>::check_indirectly_owned(728					spender.clone(),729					source.0,730					source.1,731					None,732					nesting_budget733				)?,734				<CommonError<T>>::ApprovedValueTooLow,735			);736			return Ok(());737		}738		if <Allowance<T>>::get((collection.id, token)).as_ref() == Some(spender) {739			return Ok(());740		}741		ensure!(742			collection.ignores_allowance(spender),743			<CommonError<T>>::ApprovedValueTooLow744		);745		Ok(())746	}747748	pub fn transfer_from(749		collection: &NonfungibleHandle<T>,750		spender: &T::CrossAccountId,751		from: &T::CrossAccountId,752		to: &T::CrossAccountId,753		token: TokenId,754		nesting_budget: &dyn Budget,755	) -> DispatchResult {756		Self::check_allowed(collection, spender, from, token, nesting_budget)?;757758		// =========759760		// Allowance is reset in [`transfer`]761		Self::transfer(collection, from, to, token, nesting_budget)762	}763764	pub fn burn_from(765		collection: &NonfungibleHandle<T>,766		spender: &T::CrossAccountId,767		from: &T::CrossAccountId,768		token: TokenId,769		nesting_budget: &dyn Budget,770	) -> DispatchResult {771		Self::check_allowed(collection, spender, from, token, nesting_budget)?;772773		// =========774775		Self::burn(collection, from, token)776	}777778	pub fn set_variable_metadata(779		collection: &NonfungibleHandle<T>,780		sender: &T::CrossAccountId,781		token: TokenId,782		data: BoundedVec<u8, CustomDataLimit>,783	) -> DispatchResult {784		let token_data =785			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;786		collection.check_can_update_meta(sender, &token_data.owner)?;787788		// =========789790		<TokenData<T>>::insert(791			(collection.id, token),792			ItemData {793				variable_data: data,794				..token_data795			},796		);797		Ok(())798	}799800	pub fn check_nesting(801		handle: &NonfungibleHandle<T>,802		sender: T::CrossAccountId,803		from: (CollectionId, TokenId),804		under: TokenId,805		nesting_budget: &dyn Budget,806	) -> DispatchResult {807		fn ensure_sender_allowed<T: Config>(808			collection: CollectionId,809			token: TokenId,810			for_nest: (CollectionId, TokenId),811			sender: T::CrossAccountId,812			budget: &dyn Budget,813		) -> DispatchResult {814			ensure!(815				<PalletStructure<T>>::check_indirectly_owned(816					sender,817					collection,818					token,819					Some(for_nest),820					budget821				)?,822				<CommonError<T>>::OnlyOwnerAllowedToNest,823			);824			Ok(())825		}826		match handle.limits.nesting_rule() {827			NestingRule::Disabled => fail!(<CommonError<T>>::NestingIsDisabled),828			NestingRule::Owner => {829				ensure_sender_allowed::<T>(handle.id, under, from, sender, nesting_budget)?830			}831			NestingRule::OwnerRestricted(whitelist) => {832				ensure!(833					whitelist.contains(&from.0),834					<CommonError<T>>::SourceCollectionIsNotAllowedToNest835				);836				ensure_sender_allowed::<T>(handle.id, under, from, sender, nesting_budget)?837			}838		}839		Ok(())840	}841842	/// Delegated to `create_multiple_items`843	pub fn create_item(844		collection: &NonfungibleHandle<T>,845		sender: &T::CrossAccountId,846		data: CreateItemData<T>,847		nesting_budget: &dyn Budget,848	) -> DispatchResult {849		Self::create_multiple_items(collection, sender, vec![data], nesting_budget)850	}851}
modifiedpallets/refungible/Cargo.tomldiffbeforeafterboth
--- a/pallets/refungible/Cargo.toml
+++ b/pallets/refungible/Cargo.toml
@@ -16,7 +16,7 @@
 sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
-pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 pallet-common = { default-features = false, path = '../common' }
 pallet-structure = { default-features = false, path = '../structure' }
 up-data-structs = { default-features = false, path = '../../primitives/data-structs' }
modifiedpallets/unique/Cargo.tomldiffbeforeafterboth
--- a/pallets/unique/Cargo.toml
+++ b/pallets/unique/Cargo.toml
@@ -83,5 +83,5 @@
 scale-info = { version = "2.0.1", default-features = false, features = [
     "derive",
 ] }
-pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 pallet-common = { default-features = false, path = "../common" }
modifiedprimitives/data-structs/Cargo.tomldiffbeforeafterboth
--- a/primitives/data-structs/Cargo.toml
+++ b/primitives/data-structs/Cargo.toml
@@ -23,9 +23,9 @@
 sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
-derivative = "2.2.0"
+derivative = { version = "2.2.0", features = ["use_core"] }
 struct-versioning = { path = "../../crates/struct-versioning" }
-pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 
 [features]
 default = ["std"]
modifiedprimitives/rpc/Cargo.tomldiffbeforeafterboth
--- a/primitives/rpc/Cargo.toml
+++ b/primitives/rpc/Cargo.toml
@@ -14,7 +14,7 @@
 sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 sp-api = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
 sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
-pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 
 [features]
 default = ["std"]
modifiedruntime/common/Cargo.tomldiffbeforeafterboth
--- a/runtime/common/Cargo.toml
+++ b/runtime/common/Cargo.toml
@@ -101,9 +101,9 @@
 [dependencies.fp-rpc]
 default-features = false
 git = "https://github.com/uniquenetwork/frontier"
-branch = "unique-polkadot-v0.9.21"
+branch = "unique-polkadot-v0.9.21-logs"
 
 [dependencies]
-pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 evm-coder = { default-features = false, path = '../../crates/evm-coder' }
 up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = 'polkadot-v0.9.21' }
modifiedruntime/opal/Cargo.tomldiffbeforeafterboth
--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -397,7 +397,7 @@
 derivative = "2.2.0"
 pallet-unique = { path = '../../pallets/unique', default-features = false }
 up-rpc = { path = "../../primitives/rpc", default-features = false }
-fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 pallet-inflation = { path = '../../pallets/inflation', default-features = false }
 up-data-structs = { path = '../../primitives/data-structs', default-features = false }
 pallet-common = { default-features = false, path = "../../pallets/common" }
@@ -412,11 +412,11 @@
 pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }
 pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }
 pallet-evm-coder-substrate = { default-features = false, path = "../../pallets/evm-coder-substrate" }
-pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 
 ################################################################################
 # Build Dependencies
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -821,7 +821,6 @@
 );
 
 impl pallet_evm_coder_substrate::Config for Runtime {
-	type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;
 	type GasWeightMapping = FixedGasWeightMapping;
 }
 
@@ -1070,6 +1069,7 @@
 	frame_system::CheckWeight<Runtime>,
 	pallet_charge_transaction::ChargeTransactionPayment<Runtime>,
 	//pallet_contract_helpers::ContractHelpersExtension<Runtime>,
+	pallet_ethereum::FakeTransactionFinalizer<Runtime>,
 );
 /// Unchecked extrinsic type as expected by this runtime.
 pub type UncheckedExtrinsic =
modifiedruntime/quartz/Cargo.tomldiffbeforeafterboth
--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -397,7 +397,7 @@
 derivative = "2.2.0"
 pallet-unique = { path = '../../pallets/unique', default-features = false }
 up-rpc = { path = "../../primitives/rpc", default-features = false }
-fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 pallet-inflation = { path = '../../pallets/inflation', default-features = false }
 up-data-structs = { path = '../../primitives/data-structs', default-features = false }
 pallet-common = { default-features = false, path = "../../pallets/common" }
@@ -412,11 +412,11 @@
 pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }
 pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }
 pallet-evm-coder-substrate = { default-features = false, path = "../../pallets/evm-coder-substrate" }
-pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 
 ################################################################################
 # Build Dependencies
modifiedruntime/quartz/src/lib.rsdiffbeforeafterboth
--- a/runtime/quartz/src/lib.rs
+++ b/runtime/quartz/src/lib.rs
@@ -793,7 +793,6 @@
 );
 
 impl pallet_evm_coder_substrate::Config for Runtime {
-	type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;
 	type GasWeightMapping = FixedGasWeightMapping;
 }
 
@@ -1048,6 +1047,7 @@
 	frame_system::CheckWeight<Runtime>,
 	pallet_charge_transaction::ChargeTransactionPayment<Runtime>,
 	//pallet_contract_helpers::ContractHelpersExtension<Runtime>,
+	pallet_ethereum::FakeTransactionFinalizer<Runtime>,
 );
 /// Unchecked extrinsic type as expected by this runtime.
 pub type UncheckedExtrinsic =
modifiedruntime/tests/Cargo.tomldiffbeforeafterboth
--- a/runtime/tests/Cargo.toml
+++ b/runtime/tests/Cargo.toml
@@ -12,7 +12,7 @@
 sp-io = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.21' }
 sp-runtime = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.21' }
 
-fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 
 frame-support = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.21' }
 frame-system = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.21' }
@@ -21,8 +21,8 @@
 pallet-transaction-payment = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.21' }
 pallet-timestamp = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.21' }
 
-pallet-evm = { default-features = false, git = 'https://github.com/uniquenetwork/frontier', branch = 'unique-polkadot-v0.9.21' }
-pallet-ethereum = { default-features = false, git = 'https://github.com/uniquenetwork/frontier', branch = 'unique-polkadot-v0.9.21' }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 
 pallet-common = { path = '../../pallets/common' }
 pallet-structure = { path = '../../pallets/structure' }
modifiedruntime/tests/src/lib.rsdiffbeforeafterboth
--- a/runtime/tests/src/lib.rs
+++ b/runtime/tests/src/lib.rs
@@ -16,10 +16,10 @@
 
 #![allow(clippy::from_over_into)]
 
-use sp_core::{H160, H256};
+use sp_core::{H256, U256};
 use frame_support::{
 	parameter_types,
-	traits::{Everything, ConstU32},
+	traits::{Everything, ConstU32, ConstU64},
 	weights::IdentityFee,
 };
 use sp_runtime::{
@@ -28,7 +28,9 @@
 };
 use pallet_transaction_payment::{CurrencyAdapter};
 use frame_system as system;
-use pallet_evm::{AddressMapping, runner::stack::MaybeMirroredLog, account::CrossAccountId};
+use pallet_evm::{
+	AddressMapping, account::CrossAccountId, EnsureAddressNever, SubstrateBlockHashMapping,
+};
 use fp_evm_mapping::EvmBackwardsAddressMapping;
 use parity_scale_codec::{Encode, Decode, MaxEncodedLen};
 use scale_info::TypeInfo;
@@ -181,13 +183,31 @@
 	}
 }
 
-pub struct TestEtheremTransactionSender;
-impl pallet_ethereum::EthereumTransactionSender for TestEtheremTransactionSender {
-	fn submit_logs_transaction(_source: H160, _logs: Vec<MaybeMirroredLog>) {}
+parameter_types! {
+	pub BlockGasLimit: U256 = 0u32.into();
 }
 
+impl pallet_evm::Config for Test {
+	type Event = ();
+	type FeeCalculator = ();
+	type GasWeightMapping = ();
+	type CallOrigin = EnsureAddressNever<Self::CrossAccountId>;
+	type WithdrawOrigin = EnsureAddressNever<Self::CrossAccountId>;
+	type AddressMapping = TestEvmAddressMapping;
+	type Currency = Balances;
+	type PrecompilesType = ();
+	type PrecompilesValue = ();
+	type Runner = pallet_evm::runner::stack::Runner<Self>;
+	type ChainId = ConstU64<0>;
+	type BlockGasLimit = BlockGasLimit;
+	type OnMethodCall = ();
+	type OnCreate = ();
+	type OnChargeTransaction = ();
+	type FindAuthor = ();
+	type BlockHashMapping = SubstrateBlockHashMapping<Self>;
+	type TransactionValidityHack = ();
+}
 impl pallet_evm_coder_substrate::Config for Test {
-	type EthereumTransactionSender = TestEtheremTransactionSender;
 	type GasWeightMapping = ();
 }
 
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -411,12 +411,12 @@
 pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }
 pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }
 pallet-evm-coder-substrate = { default-features = false, path = "../../pallets/evm-coder-substrate" }
-pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
-fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
+fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
 
 ################################################################################
 # Build Dependencies
modifiedruntime/unique/src/lib.rsdiffbeforeafterboth
--- a/runtime/unique/src/lib.rs
+++ b/runtime/unique/src/lib.rs
@@ -792,7 +792,6 @@
 );
 
 impl pallet_evm_coder_substrate::Config for Runtime {
-	type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;
 	type GasWeightMapping = FixedGasWeightMapping;
 }
 
@@ -1046,6 +1045,7 @@
 	frame_system::CheckWeight<Runtime>,
 	pallet_charge_transaction::ChargeTransactionPayment<Runtime>,
 	//pallet_contract_helpers::ContractHelpersExtension<Runtime>,
+	pallet_ethereum::FakeTransactionFinalizer<Runtime>,
 );
 /// Unchecked extrinsic type as expected by this runtime.
 pub type UncheckedExtrinsic =
modifiedtests/src/substrate/substrate-api.tsdiffbeforeafterboth
--- a/tests/src/substrate/substrate-api.ts
+++ b/tests/src/substrate/substrate-api.ts
@@ -34,6 +34,10 @@
         extrinsic: {},
         payload: {},
       },
+      FakeTransactionFinalizer: {
+        extrinsic: {},
+        payload: {},
+      },
     },
     rpc: {
       unique: defs.unique.rpc,