difftreelog
refactor switch to new eth log logic
in: master
33 files changed
Cargo.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",
client/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" }
node/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" }
node/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" }
pallets/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",
pallets/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
}
pallets/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(())
}
pallets/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" }
pallets/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)
}
}
pallets/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"
pallets/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)
}
pallets/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
pallets/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,
);
pallets/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
pallets/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",
] }
pallets/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),
pallets/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 {
+}
+
pallets/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' }
pallets/nonfungible/src/lib.rsdiffbeforeafterboth1// 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}pallets/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' }
pallets/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" }
primitives/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"]
primitives/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"]
runtime/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' }
runtime/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
runtime/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 =
runtime/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
runtime/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 =
runtime/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' }
runtime/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 = ();
}
runtime/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
runtime/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 =
tests/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,