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

difftreelog

CORE-302 Add EvmCollection Pallet

Trubnikov Sergey2022-04-18parent: #f15380e.patch.diff
in: master

24 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5504,6 +5504,7 @@
  "pallet-ethereum",
  "pallet-evm",
  "pallet-evm-coder-substrate",
+ "pallet-evm-collection",
  "pallet-evm-contract-helpers",
  "pallet-evm-migration",
  "pallet-evm-transaction-payment",
@@ -6075,6 +6076,28 @@
 ]
 
 [[package]]
+name = "pallet-evm-collection"
+version = "0.1.0"
+dependencies = [
+ "ethereum",
+ "evm-coder",
+ "fp-evm-mapping",
+ "frame-support",
+ "frame-system",
+ "log",
+ "pallet-common",
+ "pallet-evm",
+ "pallet-evm-coder-substrate",
+ "pallet-nonfungible",
+ "parity-scale-codec",
+ "scale-info",
+ "sp-core",
+ "sp-runtime",
+ "sp-std",
+ "up-data-structs",
+]
+
+[[package]]
 name = "pallet-evm-contract-helpers"
 version = "0.1.0"
 dependencies = [
@@ -8784,6 +8807,7 @@
  "pallet-ethereum",
  "pallet-evm",
  "pallet-evm-coder-substrate",
+ "pallet-evm-collection",
  "pallet-evm-contract-helpers",
  "pallet-evm-migration",
  "pallet-evm-transaction-payment",
@@ -12845,6 +12869,7 @@
  "pallet-ethereum",
  "pallet-evm",
  "pallet-evm-coder-substrate",
+ "pallet-evm-collection",
  "pallet-evm-contract-helpers",
  "pallet-evm-migration",
  "pallet-evm-transaction-payment",
modifiedMakefilediffbeforeafterboth
--- a/Makefile
+++ b/Makefile
@@ -15,6 +15,9 @@
 CONTRACT_HELPERS_STUBS=./pallets/evm-contract-helpers/src/stubs/
 CONTRACT_HELPERS_ABI=./tests/src/eth/util/contractHelpersAbi.json
 
+COLLECTION_STUBS=./pallets/evm-collection/src/stubs/
+COLLECTION_ABI=./tests/src/eth/collectionAbi.json
+
 TESTS_API=./tests/src/eth/api/
 
 .PHONY: regenerate_solidity
@@ -32,6 +35,10 @@
 	PACKAGE=pallet-evm-contract-helpers NAME=eth::contract_helpers_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh
 	PACKAGE=pallet-evm-contract-helpers NAME=eth::contract_helpers_impl OUTPUT=$(CONTRACT_HELPERS_STUBS)/$@ ./.maintain/scripts/generate_sol.sh
 
+Collection.sol:
+	PACKAGE=pallet-evm-collection NAME=eth::contract_helpers_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh
+	PACKAGE=pallet-evm-collection NAME=eth::contract_helpers_impl OUTPUT=$(COLLECTION_STUBS)/$@ ./.maintain/scripts/generate_sol.sh
+
 UniqueFungible: UniqueFungible.sol
 	INPUT=$(FUNGIBLE_EVM_STUBS)/$< OUTPUT=$(FUNGIBLE_EVM_STUBS)/UniqueFungible.raw ./.maintain/scripts/compile_stub.sh
 	INPUT=$(FUNGIBLE_EVM_STUBS)/$< OUTPUT=$(FUNGIBLE_EVM_ABI) ./.maintain/scripts/generate_abi.sh
@@ -44,7 +51,11 @@
 	INPUT=$(CONTRACT_HELPERS_STUBS)/$< OUTPUT=$(CONTRACT_HELPERS_STUBS)/ContractHelpers.raw ./.maintain/scripts/compile_stub.sh
 	INPUT=$(CONTRACT_HELPERS_STUBS)/$< OUTPUT=$(CONTRACT_HELPERS_ABI) ./.maintain/scripts/generate_abi.sh
 
-evm_stubs: UniqueFungible UniqueNFT ContractHelpers
+Collection: Collection.sol
+	INPUT=$(COLLECTION_STUBS)/$< OUTPUT=$(COLLECTION_STUBS)/Collection.raw ./.maintain/scripts/compile_stub.sh
+	INPUT=$(COLLECTION_STUBS)/$< OUTPUT=$(COLLECTION_ABI) ./.maintain/scripts/generate_abi.sh
+
+evm_stubs: UniqueFungible UniqueNFT ContractHelpers Collection
 
 .PHONY: _bench
 _bench:
addedpallets/evm-collection/Cargo.tomldiffbeforeafterboth
--- /dev/null
+++ b/pallets/evm-collection/Cargo.toml
@@ -0,0 +1,49 @@
+[package]
+name = "pallet-evm-collection"
+version = "0.1.0"
+license = "GPLv3"
+edition = "2021"
+
+[dependencies]
+scale-info = { version = "2.0.1", default-features = false, features = [
+    "derive",
+] }
+ethereum = { version = "0.12.0", default-features = false }
+log = { default-features = false, version = "0.4.14" }
+
+# Substrate
+frame-support = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.21' }
+frame-system = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.21' }
+sp-runtime = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.21' }
+sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.21' }
+sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.21' }
+
+# Unique
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.21-logs" }
+fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.21-logs" }
+
+# Locals
+evm-coder = { default-features = false, path = '../../crates/evm-coder' }
+pallet-common = { default-features = false, path = '../../pallets/common' }
+pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }
+pallet-nonfungible = { default-features = false, path = '../../pallets/nonfungible' }
+up-data-structs = { default-features = false, path = '../../primitives/data-structs' }
+
+[dependencies.codec]
+default-features = false
+features = ['derive']
+package = 'parity-scale-codec'
+version = '3.1.2'
+
+[features]
+default = ["std"]
+std = [
+    "frame-support/std",
+    "frame-system/std",
+    "sp-runtime/std",
+    "sp-std/std",
+    "sp-core/std",
+    "evm-coder/std",
+    "pallet-evm-coder-substrate/std",
+    "pallet-evm/std",
+]
addedpallets/evm-collection/src/eth.rsdiffbeforeafterboth
--- /dev/null
+++ b/pallets/evm-collection/src/eth.rs
@@ -0,0 +1,169 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+use core::marker::PhantomData;
+use evm_coder::{abi::AbiWriter, execution::*, generate_stubgen, solidity_interface, types::*, ToLog};
+use ethereum as _;
+use pallet_common::CollectionById;
+use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
+use pallet_evm::{
+	ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure,
+	account::CrossAccountId, Pallet as PalletEvm,
+};
+use sp_core::H160;
+use up_data_structs::{
+	CreateCollectionData, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,
+	MAX_COLLECTION_NAME_LENGTH,
+};
+use crate::{Config, Pallet};
+use frame_support::traits::Get;
+
+use sp_std::vec::Vec;
+use alloc::format;
+
+struct EvmCollection<T: Config>(SubstrateRecorder<T>);
+impl<T: Config> WithRecorder<T> for EvmCollection<T> {
+	fn recorder(&self) -> &SubstrateRecorder<T> {
+		&self.0
+	}
+
+	fn into_recorder(self) -> SubstrateRecorder<T> {
+		self.0
+	}
+}
+
+#[derive(ToLog)]
+pub enum CollectionEvent {
+	CollectionCreated {
+		#[indexed]
+		owner: address,
+		#[indexed]
+		collection_id: address,
+	},
+}
+
+#[solidity_interface(name = "Collection")]
+impl<T: Config> EvmCollection<T> {
+	fn create_721_collection(
+		&self,
+		caller: caller,
+		name: string,
+		description: string,
+		token_prefix: string,
+	) -> Result<address> {
+		let caller = T::CrossAccountId::from_eth(caller);
+		let name = name
+			.encode_utf16()
+			.collect::<Vec<u16>>()
+			.try_into()
+			.map_err(|_| error_feild_too_long("name", MAX_COLLECTION_NAME_LENGTH))?;
+		let description = description
+			.encode_utf16()
+			.collect::<Vec<u16>>()
+			.try_into()
+			.map_err(|_| error_feild_too_long("description", MAX_COLLECTION_DESCRIPTION_LENGTH))?;
+		let token_prefix = token_prefix
+			.into_bytes()
+			.try_into()
+			.map_err(|_| error_feild_too_long("token_prefix", MAX_TOKEN_PREFIX_LENGTH))?;
+
+		let data = CreateCollectionData {
+			name,
+			description,
+			token_prefix,
+			..Default::default()
+		};
+
+		let collection_id =
+			<pallet_nonfungible::Pallet<T>>::init_collection(caller.as_sub().clone(), data)
+				.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
+
+		let address = pallet_common::eth::collection_id_to_address(collection_id);
+		<PalletEvm<T>>::deposit_log(
+			CollectionEvent::CollectionCreated {
+				owner: *caller.as_eth(),
+				collection_id: address,
+			}
+			.to_log(address),
+		);
+		Ok(address)
+	}
+
+	// fn set_sponsor(collection_id: address, sponsor: address) -> Result<void> {
+	// 	let collection_id =
+	// 		pallet_common::eth::map_eth_to_id(&collection_id).ok_or(Error::Revert("".into()))?;
+	// 	let mut collection = <CollectionById<T>>::get(collection_id).ok_or(Error::Revert("".into()))?;
+	// 	let sponsor = T::CrossAccountId::from_eth(sponsor);
+	// 	collection.sponsorship = SponsorshipState::Unconfirmed(sponsor.as_sub().clone());
+	// 	<CollectionById<T>>::insert(collection_id, collection);
+	// 	Ok(())
+	// }
+
+	// fn set_offchain_shema(shema: string) -> Result<void> {
+	// 	Ok(())
+	// }
+
+	// fn set_const_on_chain_schema(shema: string) -> Result<void> {
+	// 	Ok(())
+	// }
+
+	// fn set_variable_on_chain_schema(shema: string) -> Result<void> {
+	// 	Ok(())
+	// }
+
+	// fn set_limits(limits: string) -> Result<void> {
+	// 	Ok(())
+	// }
+}
+
+fn error_feild_too_long(feild: &str, bound: u32) -> Error {
+	Error::Revert(format!("{} is too long. Max length is {}.", feild, bound))
+}
+
+pub struct CollectionOnMethodCall<T: Config>(PhantomData<*const T>);
+impl<T: Config> OnMethodCall<T> for CollectionOnMethodCall<T> {
+	fn is_reserved(contract: &sp_core::H160) -> bool {
+		contract == &T::ContractAddress::get()
+	}
+
+	fn is_used(contract: &sp_core::H160) -> bool {
+		contract == &T::ContractAddress::get()
+	}
+
+	fn call(
+		source: &sp_core::H160,
+		target: &sp_core::H160,
+		gas_left: u64,
+		input: &[u8],
+		value: sp_core::U256,
+	) -> Option<PrecompileResult> {
+		// TODO: Extract to another OnMethodCall handler
+		if target != &T::ContractAddress::get() {
+			return None;
+		}
+
+		let helpers = EvmCollection::<T>(SubstrateRecorder::<T>::new(gas_left));
+		pallet_evm_coder_substrate::call(*source, helpers, value, input)
+	}
+
+	fn get_code(contract: &sp_core::H160) -> Option<Vec<u8>> {
+		(contract == &T::ContractAddress::get())
+			.then(|| include_bytes!("./stubs/Collection.raw").to_vec())
+	}
+}
+
+generate_stubgen!(collection_impl, CollectionCall<()>, true);
+generate_stubgen!(collection_iface, CollectionCall<()>, false);
addedpallets/evm-collection/src/lib.rsdiffbeforeafterboth
--- /dev/null
+++ b/pallets/evm-collection/src/lib.rs
@@ -0,0 +1,53 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+#![cfg_attr(not(feature = "std"), no_std)]
+
+extern crate alloc;
+
+use codec::{Decode, Encode, MaxEncodedLen};
+pub use pallet::*;
+pub use eth::*;
+use scale_info::TypeInfo;
+pub mod eth;
+
+#[frame_support::pallet]
+pub mod pallet {
+	pub use super::*;
+	use evm_coder::execution::Result;
+	use frame_support::pallet_prelude::*;
+	use sp_core::H160;
+
+	#[pallet::config]
+	pub trait Config:
+		frame_system::Config + pallet_evm_coder_substrate::Config + pallet_evm::account::Config + pallet_nonfungible::Config
+	{
+		type ContractAddress: Get<H160>;
+	}
+
+	#[pallet::error]
+	pub enum Error<T> {
+		/// This method is only executable by owner
+		NoPermission,
+	}
+
+	#[pallet::pallet]
+	// #[pallet::generate_store(pub(super) trait Store)]
+	pub struct Pallet<T>(_);
+
+
+	impl<T: Config> Pallet<T> {}
+}
addedpallets/evm-collection/src/stubs/Collection.rawdiffbeforeafterboth

binary blob — no preview

addedpallets/evm-collection/src/stubs/Collection.soldiffbeforeafterboth
--- /dev/null
+++ b/pallets/evm-collection/src/stubs/Collection.sol
@@ -0,0 +1,161 @@
+// SPDX-License-Identifier: OTHER
+// This code is automatically generated
+
+pragma solidity >=0.8.0 <0.9.0;
+
+// Common stubs holder
+contract Dummy {
+	uint8 dummy;
+	string stub_error = "this contract is implemented in native";
+}
+
+contract ERC165 is Dummy {
+	function supportsInterface(bytes4 interfaceID)
+		external
+		view
+		returns (bool)
+	{
+		require(false, stub_error);
+		interfaceID;
+		return true;
+	}
+}
+
+// Selector: ee5467a8
+contract Collection is Dummy, ERC165 {
+	// Selector: contractOwner(address) 5152b14c
+	function contractOwner(address contractAddress)
+		public
+		view
+		returns (address)
+	{
+		require(false, stub_error);
+		contractAddress;
+		dummy;
+		return 0x0000000000000000000000000000000000000000;
+	}
+
+	// Selector: sponsoringEnabled(address) 6027dc61
+	function sponsoringEnabled(address contractAddress)
+		public
+		view
+		returns (bool)
+	{
+		require(false, stub_error);
+		contractAddress;
+		dummy;
+		return false;
+	}
+
+	// Deprecated
+	//
+	// Selector: toggleSponsoring(address,bool) fcac6d86
+	function toggleSponsoring(address contractAddress, bool enabled) public {
+		require(false, stub_error);
+		contractAddress;
+		enabled;
+		dummy = 0;
+	}
+
+	// Selector: setSponsoringMode(address,uint8) fde8a560
+	function setSponsoringMode(address contractAddress, uint8 mode) public {
+		require(false, stub_error);
+		contractAddress;
+		mode;
+		dummy = 0;
+	}
+
+	// Selector: sponsoringMode(address) b70c7267
+	function sponsoringMode(address contractAddress)
+		public
+		view
+		returns (uint8)
+	{
+		require(false, stub_error);
+		contractAddress;
+		dummy;
+		return 0;
+	}
+
+	// Selector: setSponsoringRateLimit(address,uint32) 77b6c908
+	function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)
+		public
+	{
+		require(false, stub_error);
+		contractAddress;
+		rateLimit;
+		dummy = 0;
+	}
+
+	// Selector: getSponsoringRateLimit(address) 610cfabd
+	function getSponsoringRateLimit(address contractAddress)
+		public
+		view
+		returns (uint32)
+	{
+		require(false, stub_error);
+		contractAddress;
+		dummy;
+		return 0;
+	}
+
+	// Selector: allowed(address,address) 5c658165
+	function allowed(address contractAddress, address user)
+		public
+		view
+		returns (bool)
+	{
+		require(false, stub_error);
+		contractAddress;
+		user;
+		dummy;
+		return false;
+	}
+
+	// Selector: allowlistEnabled(address) c772ef6c
+	function allowlistEnabled(address contractAddress)
+		public
+		view
+		returns (bool)
+	{
+		require(false, stub_error);
+		contractAddress;
+		dummy;
+		return false;
+	}
+
+	// Selector: toggleAllowlist(address,bool) 36de20f5
+	function toggleAllowlist(address contractAddress, bool enabled) public {
+		require(false, stub_error);
+		contractAddress;
+		enabled;
+		dummy = 0;
+	}
+
+	// Selector: toggleAllowed(address,address,bool) 4706cc1c
+	function toggleAllowed(
+		address contractAddress,
+		address user,
+		bool allowed
+	) public {
+		require(false, stub_error);
+		contractAddress;
+		user;
+		allowed;
+		dummy = 0;
+	}
+
+	// Selector: create721Collection(string,string,string) 951c0151
+	function create721Collection(
+		string memory name,
+		string memory description,
+		string memory tokenPrefix
+	) public view returns (address) {
+		require(false, stub_error);
+		name;
+		description;
+		tokenPrefix;
+		dummy;
+		return 0x0000000000000000000000000000000000000000;
+	}
+}
modifiedpallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth
--- a/pallets/evm-contract-helpers/src/eth.rs
+++ b/pallets/evm-contract-helpers/src/eth.rs
@@ -20,20 +20,15 @@
 use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
 use pallet_evm::{
 	ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure,
-	account::CrossAccountId, Pallet as PalletEvm
+	account::CrossAccountId
 };
 use sp_core::H160;
-use up_data_structs::{
-	CreateCollectionData, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,
-	MAX_COLLECTION_NAME_LENGTH,
-};
 use crate::{
 	AllowlistEnabled, Config, Owner, Pallet, SponsorBasket, SponsoringRateLimit, SponsoringModeT,
 };
 use frame_support::traits::Get;
 use up_sponsorship::SponsorshipHandler;
 use sp_std::vec::Vec;
-use alloc::format;
 
 struct ContractHelpers<T: Config>(SubstrateRecorder<T>);
 impl<T: Config> WithRecorder<T> for ContractHelpers<T> {
@@ -142,56 +137,6 @@
 		<Pallet<T>>::toggle_allowed(contract_address, user, allowed);
 		Ok(())
 	}
-
-	fn create_721_collection(
-		&self,
-		caller: caller,
-		name: string,
-		description: string,
-		token_prefix: string,
-	) -> Result<address> {
-		let caller = T::CrossAccountId::from_eth(caller);
-		let name = name
-			.encode_utf16()
-			.collect::<Vec<u16>>()
-			.try_into()
-			.map_err(|_| error_feild_too_long("name", MAX_COLLECTION_NAME_LENGTH))?;
-		let description = description
-			.encode_utf16()
-			.collect::<Vec<u16>>()
-			.try_into()
-			.map_err(|_| error_feild_too_long("description", MAX_COLLECTION_DESCRIPTION_LENGTH))?;
-		let token_prefix = token_prefix
-			.into_bytes()
-			.try_into()
-			.map_err(|_| error_feild_too_long("token_prefix", MAX_TOKEN_PREFIX_LENGTH))?;
-
-		let data = CreateCollectionData {
-			name,
-			description,
-			token_prefix,
-			..Default::default()
-		};
-
-		let collection_id =
-			<pallet_nonfungible::Pallet<T>>::init_collection(caller.as_sub().clone(), data)
-				.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
-
-		let address = pallet_common::eth::collection_id_to_address(collection_id);
-
-		<PalletEvm<T>>::deposit_log(
-			ContractHelperEvent::CollectionCreated {
-				owner: *caller.as_eth(),
-				collection_id: address,
-			}
-			.to_log(address),
-		);
-		Ok(address)
-	}
-}
-
-fn error_feild_too_long(feild: &str, bound: u32) -> Error {
-	Error::Revert(format!("{} is too long. Max length is {}.", feild, bound))
 }
 
 pub struct HelpersOnMethodCall<T: Config>(PhantomData<*const T>);
modifiedpallets/evm-contract-helpers/src/lib.rsdiffbeforeafterboth
--- a/pallets/evm-contract-helpers/src/lib.rs
+++ b/pallets/evm-contract-helpers/src/lib.rs
@@ -16,9 +16,6 @@
 
 #![cfg_attr(not(feature = "std"), no_std)]
 
-#[macro_use(format)]
-extern crate alloc;
-
 use codec::{Decode, Encode, MaxEncodedLen};
 pub use pallet::*;
 pub use eth::*;
addedpallets/evm-contract-helpers/src/stubs/Collection.soldiffbeforeafterboth
--- /dev/null
+++ b/pallets/evm-contract-helpers/src/stubs/Collection.sol
@@ -0,0 +1,192 @@
+// SPDX-License-Identifier: OTHER
+// This code is automatically generated
+
+pragma solidity >=0.8.0 <0.9.0;
+
+// Common stubs holder
+contract Dummy {
+	uint8 dummy;
+	string stub_error = "this contract is implemented in native";
+}
+
+contract ERC165 is Dummy {
+	function supportsInterface(bytes4 interfaceID)
+		external
+		view
+		returns (bool)
+	{
+		require(false, stub_error);
+		interfaceID;
+		return true;
+	}
+}
+
+// Selector: 61f17ed8
+contract ContractHelpers is Dummy, ERC165 {
+	// Selector: contractOwner(address) 5152b14c
+	function contractOwner(address contractAddress)
+		public
+		view
+		returns (address)
+	{
+		require(false, stub_error);
+		contractAddress;
+		dummy;
+		return 0x0000000000000000000000000000000000000000;
+	}
+
+	// Selector: sponsoringEnabled(address) 6027dc61
+	function sponsoringEnabled(address contractAddress)
+		public
+		view
+		returns (bool)
+	{
+		require(false, stub_error);
+		contractAddress;
+		dummy;
+		return false;
+	}
+
+	// Deprecated
+	//
+	// Selector: toggleSponsoring(address,bool) fcac6d86
+	function toggleSponsoring(address contractAddress, bool enabled) public {
+		require(false, stub_error);
+		contractAddress;
+		enabled;
+		dummy = 0;
+	}
+
+	// Selector: setSponsoringMode(address,uint8) fde8a560
+	function setSponsoringMode(address contractAddress, uint8 mode) public {
+		require(false, stub_error);
+		contractAddress;
+		mode;
+		dummy = 0;
+	}
+
+	// Selector: sponsoringMode(address) b70c7267
+	function sponsoringMode(address contractAddress)
+		public
+		view
+		returns (uint8)
+	{
+		require(false, stub_error);
+		contractAddress;
+		dummy;
+		return 0;
+	}
+
+	// Selector: setSponsoringRateLimit(address,uint32) 77b6c908
+	function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)
+		public
+	{
+		require(false, stub_error);
+		contractAddress;
+		rateLimit;
+		dummy = 0;
+	}
+
+	// Selector: getSponsoringRateLimit(address) 610cfabd
+	function getSponsoringRateLimit(address contractAddress)
+		public
+		view
+		returns (uint32)
+	{
+		require(false, stub_error);
+		contractAddress;
+		dummy;
+		return 0;
+	}
+
+	// Selector: allowed(address,address) 5c658165
+	function allowed(address contractAddress, address user)
+		public
+		view
+		returns (bool)
+	{
+		require(false, stub_error);
+		contractAddress;
+		user;
+		dummy;
+		return false;
+	}
+
+	// Selector: allowlistEnabled(address) c772ef6c
+	function allowlistEnabled(address contractAddress)
+		public
+		view
+		returns (bool)
+	{
+		require(false, stub_error);
+		contractAddress;
+		dummy;
+		return false;
+	}
+
+	// Selector: toggleAllowlist(address,bool) 36de20f5
+	function toggleAllowlist(address contractAddress, bool enabled) public {
+		require(false, stub_error);
+		contractAddress;
+		enabled;
+		dummy = 0;
+	}
+
+	// Selector: toggleAllowed(address,address,bool) 4706cc1c
+	function toggleAllowed(
+		address contractAddress,
+		address user,
+		bool allowed
+	) public {
+		require(false, stub_error);
+		contractAddress;
+		user;
+		allowed;
+		dummy = 0;
+	}
+
+	// Selector: create721Collection(string,string,string) 951c0151
+	function create721Collection(
+		string memory name,
+		string memory description,
+		string memory tokenPrefix
+	) public view returns (address) {
+		require(false, stub_error);
+		name;
+		description;
+		tokenPrefix;
+		dummy;
+		return 0x0000000000000000000000000000000000000000;
+	}
+
+	// Selector: setSponsor(address,address) f01fba93
+	function setSponsor(address collectionId, address sponsor) public pure {
+		require(false, stub_error);
+		collectionId;
+		sponsor;
+	}
+
+	// Selector: setOffchainShema(string) c3aa408b
+	function setOffchainShema(string memory shema) public pure {
+		require(false, stub_error);
+		shema;
+	}
+
+	// Selector: setConstOnChainSchema(string) b284d8df
+	function setConstOnChainSchema(string memory shema) public pure {
+		require(false, stub_error);
+		shema;
+	}
+
+	// Selector: setVariableOnChainSchema(string) 7c5f0fea
+	function setVariableOnChainSchema(string memory shema) public pure {
+		require(false, stub_error);
+		shema;
+	}
+
+	// Selector: setLimits(string) 72cb345d
+	function setLimits(string memory limits) public pure {
+		require(false, stub_error);
+		limits;
+	}
+}
modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.soldiffbeforeafterboth
--- a/pallets/evm-contract-helpers/src/stubs/ContractHelpers.sol
+++ b/pallets/evm-contract-helpers/src/stubs/ContractHelpers.sol
@@ -21,7 +21,7 @@
 	}
 }
 
-// Selector: ee5467a8
+// Selector: 7b4866f9
 contract ContractHelpers is Dummy, ERC165 {
 	// Selector: contractOwner(address) 5152b14c
 	function contractOwner(address contractAddress)
@@ -143,19 +143,5 @@
 		user;
 		allowed;
 		dummy = 0;
-	}
-
-	// Selector: create721Collection(string,string,string) 951c0151
-	function create721Collection(
-		string memory name,
-		string memory description,
-		string memory tokenPrefix
-	) public view returns (address) {
-		require(false, stub_error);
-		name;
-		description;
-		tokenPrefix;
-		dummy;
-		return 0x0000000000000000000000000000000000000000;
 	}
 }
modifiedruntime/opal/Cargo.tomldiffbeforeafterboth
--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -74,6 +74,7 @@
     'pallet-evm/std',
     'pallet-evm-migration/std',
     'pallet-evm-contract-helpers/std',
+    'pallet-evm-collection/std',
     'pallet-evm-transaction-payment/std',
     'pallet-evm-coder-substrate/std',
     'pallet-ethereum/std',
@@ -417,6 +418,7 @@
 pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.21", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }
 pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }
 pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }
+pallet-evm-collection = { path = '../../pallets/evm-collection', 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-logs" }
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -49,7 +49,7 @@
 // A few exports that help ease life for downstream crates.
 pub use pallet_balances::Call as BalancesCall;
 pub use pallet_evm::{
-	EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _,
+	EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _, OnMethodCall,
 };
 pub use frame_support::{
 	construct_runtime, match_types,
@@ -306,6 +306,7 @@
 		pallet_evm_migration::OnMethodCall<Self>,
 		pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,
 		CollectionDispatchT<Self>,
+		pallet_evm_collection::CollectionOnMethodCall<Self>,
 	);
 	type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;
 	type ChainId = ChainId;
@@ -974,6 +975,11 @@
 	pub const HelpersContractAddress: H160 = H160([
 		0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,
 	]);
+	
+	// 0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f
+	pub const EvmCollectionAddress: H160 = H160([
+		0x6c, 0x4e, 0x9f, 0xe1, 0xae, 0x37, 0xa4, 0x1e, 0x93, 0xce, 0xe4, 0x29, 0xe8, 0xe1, 0x88, 0x1a, 0xbd, 0xcb, 0xb5, 0x4f,
+	]);
 }
 
 impl pallet_evm_contract_helpers::Config for Runtime {
@@ -981,6 +987,10 @@
 	type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;
 }
 
+impl pallet_evm_collection::Config for Runtime {
+	type ContractAddress = EvmCollectionAddress;
+}
+
 construct_runtime!(
 	pub enum Runtime where
 		Block = Block,
@@ -1033,6 +1043,7 @@
 		EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,
 		EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,
 		EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,
+		EvmCollection: pallet_evm_collection::{Pallet} = 154,
 	}
 );
 
modifiedruntime/quartz/Cargo.tomldiffbeforeafterboth
--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -74,6 +74,7 @@
     'pallet-evm/std',
     'pallet-evm-migration/std',
     'pallet-evm-contract-helpers/std',
+    'pallet-evm-collection/std',
     'pallet-evm-transaction-payment/std',
     'pallet-evm-coder-substrate/std',
     'pallet-ethereum/std',
@@ -422,6 +423,7 @@
 pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.21", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }
 pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }
 pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }
+pallet-evm-collection = { path = '../../pallets/evm-collection', 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-logs" }
modifiedruntime/quartz/src/lib.rsdiffbeforeafterboth
--- a/runtime/quartz/src/lib.rs
+++ b/runtime/quartz/src/lib.rs
@@ -79,7 +79,7 @@
 };
 use smallvec::smallvec;
 use codec::{Encode, Decode};
-use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping};
+use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping, OnMethodCall};
 use fp_rpc::TransactionStatus;
 use sp_runtime::{
 	traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},
@@ -278,6 +278,7 @@
 		pallet_evm_migration::OnMethodCall<Self>,
 		pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,
 		CollectionDispatchT<Self>,
+		pallet_evm_collection::CollectionOnMethodCall<Self>,
 	);
 	type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;
 	type ChainId = ChainId;
@@ -951,6 +952,11 @@
 	pub const HelpersContractAddress: H160 = H160([
 		0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,
 	]);
+		
+	// 0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f
+	pub const EvmCollectionAddress: H160 = H160([
+		0x6c, 0x4e, 0x9f, 0xe1, 0xae, 0x37, 0xa4, 0x1e, 0x93, 0xce, 0xe4, 0x29, 0xe8, 0xe1, 0x88, 0x1a, 0xbd, 0xcb, 0xb5, 0x4f,
+	]);
 }
 
 impl pallet_evm_contract_helpers::Config for Runtime {
@@ -958,6 +964,10 @@
 	type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;
 }
 
+impl pallet_evm_collection::Config for Runtime {
+	type ContractAddress = EvmCollectionAddress;
+}
+
 construct_runtime!(
 	pub enum Runtime where
 		Block = Block,
@@ -1010,6 +1020,7 @@
 		EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,
 		EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,
 		EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,
+		EvmCollection: pallet_evm_collection::{Pallet} = 154,
 	}
 );
 
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -75,6 +75,7 @@
     'pallet-evm/std',
     'pallet-evm-migration/std',
     'pallet-evm-contract-helpers/std',
+    'pallet-evm-collection/std',
     'pallet-evm-transaction-payment/std',
     'pallet-evm-coder-substrate/std',
     'pallet-ethereum/std',
@@ -414,6 +415,7 @@
 pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.21", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }
 pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }
 pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }
+pallet-evm-collection = { path = '../../pallets/evm-collection', 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-logs" }
modifiedruntime/unique/src/lib.rsdiffbeforeafterboth
before · runtime/unique/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//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.1819#![cfg_attr(not(feature = "std"), no_std)]20// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.21#![recursion_limit = "1024"]22#![allow(clippy::from_over_into, clippy::identity_op)]23#![allow(clippy::fn_to_numeric_cast_with_truncation)]24// Make the WASM binary available.25#[cfg(feature = "std")]26include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));2728use sp_api::impl_runtime_apis;29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};30use sp_runtime::DispatchError;31// #[cfg(any(feature = "std", test))]32// pub use sp_runtime::BuildStorage;3334use sp_runtime::{35	Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,36	traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion, Zero},37	transaction_validity::{TransactionSource, TransactionValidity},38	ApplyExtrinsicResult, RuntimeAppPublic,39};4041use sp_std::prelude::*;4243#[cfg(feature = "std")]44use sp_version::NativeVersion;45use sp_version::RuntimeVersion;46pub use pallet_transaction_payment::{47	Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,48};49// A few exports that help ease life for downstream crates.50pub use pallet_balances::Call as BalancesCall;51pub use pallet_evm::{52	EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _,53};54pub use frame_support::{55	construct_runtime, match_types,56	dispatch::DispatchResult,57	PalletId, parameter_types, StorageValue, ConsensusEngineId,58	traits::{59		tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,60		Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,61		OnUnbalanced, Randomness, FindAuthor, ConstU32, Imbalance,62	},63	weights::{64		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},65		DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,66		WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,67	},68};69use unique_runtime_common::{70	dispatch::{CollectionDispatchT, CollectionDispatch},71	weights::CommonWeights,72	sponsoring::UniqueSponsorshipHandler,73	eth_sponsoring::UniqueEthSponsorshipHandler,74};75use up_data_structs::*;76// use pallet_contracts::weights::WeightInfo;77// #[cfg(any(feature = "std", test))]78use frame_system::{79	self as frame_system, EnsureRoot, EnsureSigned,80	limits::{BlockWeights, BlockLength},81};82use sp_arithmetic::{83	traits::{BaseArithmetic, Unsigned},84};85use smallvec::smallvec;86use codec::{Encode, Decode};87use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping};88use fp_rpc::TransactionStatus;89use sp_runtime::{90	traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},91	transaction_validity::TransactionValidityError,92	SaturatedConversion,93};9495// pub use pallet_timestamp::Call as TimestampCall;9697// Polkadot imports98use pallet_xcm::XcmPassthrough;99use polkadot_parachain::primitives::Sibling;100use up_data_structs::mapping::{CrossTokenAddressMapping, EvmTokenAddressMapping};101use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};102use xcm_builder::{103	AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,104	EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,105	RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,106	SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,107	ParentIsPreset,108};109use xcm_executor::{Config, XcmExecutor, Assets};110use sp_std::{marker::PhantomData};111112use xcm::latest::{113	//	Xcm,114	AssetId::{Concrete},115	Fungibility::Fungible as XcmFungible,116	MultiAsset,117	Error as XcmError,118};119use xcm_executor::traits::{MatchesFungible, WeightTrader};120//use xcm_executor::traits::MatchesFungible;121use sp_runtime::traits::CheckedConversion;122123use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};124125pub const RUNTIME_NAME: &str = "unique";126pub const TOKEN_SYMBOL: &str = "UNQ";127128type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;129130impl RuntimeInstance for Runtime {131	type CrossAccountId = self::CrossAccountId;132133	type TransactionConverter = self::TransactionConverter;134135	fn get_transaction_converter() -> TransactionConverter {136		TransactionConverter137	}138}139140/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know141/// the specifics of the runtime. They can then be made to be agnostic over specific formats142/// of data like extrinsics, allowing for them to continue syncing the network through upgrades143/// to even the core data structures.144pub mod opaque {145	use sp_std::prelude::*;146	use sp_runtime::impl_opaque_keys;147	use super::Aura;148149	pub use unique_runtime_common::types::*;150151	impl_opaque_keys! {152		pub struct SessionKeys {153			pub aura: Aura,154		}155	}156}157158/// This runtime version.159pub const VERSION: RuntimeVersion = RuntimeVersion {160	spec_name: create_runtime_str!(RUNTIME_NAME),161	impl_name: create_runtime_str!(RUNTIME_NAME),162	authoring_version: 1,163	spec_version: 920000,164	impl_version: 0,165	apis: RUNTIME_API_VERSIONS,166	transaction_version: 1,167	state_version: 0,168};169170#[derive(codec::Encode, codec::Decode)]171pub enum XCMPMessage<XAccountId, XBalance> {172	/// Transfer tokens to the given account from the Parachain account.173	TransferToken(XAccountId, XBalance),174}175176/// The version information used to identify this runtime when compiled natively.177#[cfg(feature = "std")]178pub fn native_version() -> NativeVersion {179	NativeVersion {180		runtime_version: VERSION,181		can_author_with: Default::default(),182	}183}184185type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;186187pub struct DealWithFees;188impl OnUnbalanced<NegativeImbalance> for DealWithFees {189	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {190		if let Some(fees) = fees_then_tips.next() {191			// for fees, 100% to treasury192			let mut split = fees.ration(100, 0);193			if let Some(tips) = fees_then_tips.next() {194				// for tips, if any, 100% to treasury195				tips.ration_merge_into(100, 0, &mut split);196			}197			Treasury::on_unbalanced(split.0);198			// Author::on_unbalanced(split.1);199		}200	}201}202203parameter_types! {204	pub const BlockHashCount: BlockNumber = 2400;205	pub RuntimeBlockLength: BlockLength =206		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);207	pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);208	pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;209	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()210		.base_block(BlockExecutionWeight::get())211		.for_class(DispatchClass::all(), |weights| {212			weights.base_extrinsic = ExtrinsicBaseWeight::get();213		})214		.for_class(DispatchClass::Normal, |weights| {215			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);216		})217		.for_class(DispatchClass::Operational, |weights| {218			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);219			// Operational transactions have some extra reserved space, so that they220			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.221			weights.reserved = Some(222				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT223			);224		})225		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)226		.build_or_panic();227	pub const Version: RuntimeVersion = VERSION;228	pub const SS58Prefix: u16 = 7391;229}230231parameter_types! {232	pub const ChainId: u64 = 8880;233}234235pub struct FixedFee;236impl FeeCalculator for FixedFee {237	fn min_gas_price() -> U256 {238		MIN_GAS_PRICE.into()239	}240}241242// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case243// (contract, which only writes a lot of data),244// approximating on top of our real store write weight245parameter_types! {246	pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;247	pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;248	pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();249}250251/// Limiting EVM execution to 50% of block for substrate users and management tasks252/// EVM transaction consumes more weight than substrate's, so we can't rely on them being253/// scheduled fairly254const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);255parameter_types! {256	pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());257}258259pub enum FixedGasWeightMapping {}260impl GasWeightMapping for FixedGasWeightMapping {261	fn gas_to_weight(gas: u64) -> Weight {262		gas.saturating_mul(WeightPerGas::get())263	}264	fn weight_to_gas(weight: Weight) -> u64 {265		weight / WeightPerGas::get()266	}267}268269impl pallet_evm::Config for Runtime {270	type BlockGasLimit = BlockGasLimit;271	type FeeCalculator = FixedFee;272	type GasWeightMapping = FixedGasWeightMapping;273	type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;274	type CallOrigin = EnsureAddressTruncated<Self>;275	type WithdrawOrigin = EnsureAddressTruncated<Self>;276	type AddressMapping = HashedAddressMapping<Self::Hashing>;277	type PrecompilesType = ();278	type PrecompilesValue = ();279	type Currency = Balances;280	type Event = Event;281	type OnMethodCall = (282		pallet_evm_migration::OnMethodCall<Self>,283		pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,284		CollectionDispatchT<Self>,285	);286	type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;287	type ChainId = ChainId;288	type Runner = pallet_evm::runner::stack::Runner<Self>;289	type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;290	type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;291	type FindAuthor = EthereumFindAuthor<Aura>;292}293294impl pallet_evm_migration::Config for Runtime {295	type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;296}297298pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);299impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {300	fn find_author<'a, I>(digests: I) -> Option<H160>301	where302		I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,303	{304		if let Some(author_index) = F::find_author(digests) {305			let authority_id = Aura::authorities()[author_index as usize].clone();306			return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));307		}308		None309	}310}311312impl pallet_ethereum::Config for Runtime {313	type Event = Event;314	type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;315}316317impl pallet_randomness_collective_flip::Config for Runtime {}318319impl frame_system::Config for Runtime {320	/// The data to be stored in an account.321	type AccountData = pallet_balances::AccountData<Balance>;322	/// The identifier used to distinguish between accounts.323	type AccountId = AccountId;324	/// The basic call filter to use in dispatchable.325	type BaseCallFilter = Everything;326	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).327	type BlockHashCount = BlockHashCount;328	/// The maximum length of a block (in bytes).329	type BlockLength = RuntimeBlockLength;330	/// The index type for blocks.331	type BlockNumber = BlockNumber;332	/// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.333	type BlockWeights = RuntimeBlockWeights;334	/// The aggregated dispatch type that is available for extrinsics.335	type Call = Call;336	/// The weight of database operations that the runtime can invoke.337	type DbWeight = RocksDbWeight;338	/// The ubiquitous event type.339	type Event = Event;340	/// The type for hashing blocks and tries.341	type Hash = Hash;342	/// The hashing algorithm used.343	type Hashing = BlakeTwo256;344	/// The header type.345	type Header = generic::Header<BlockNumber, BlakeTwo256>;346	/// The index type for storing how many extrinsics an account has signed.347	type Index = Index;348	/// The lookup mechanism to get account ID from whatever is passed in dispatchers.349	type Lookup = AccountIdLookup<AccountId, ()>;350	/// What to do if an account is fully reaped from the system.351	type OnKilledAccount = ();352	/// What to do if a new account is created.353	type OnNewAccount = ();354	type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;355	/// The ubiquitous origin type.356	type Origin = Origin;357	/// This type is being generated by `construct_runtime!`.358	type PalletInfo = PalletInfo;359	/// This is used as an identifier of the chain. 42 is the generic substrate prefix.360	type SS58Prefix = SS58Prefix;361	/// Weight information for the extrinsics of this pallet.362	type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;363	/// Version of the runtime.364	type Version = Version;365	type MaxConsumers = ConstU32<16>;366}367368parameter_types! {369	pub const MinimumPeriod: u64 = SLOT_DURATION / 2;370}371372impl pallet_timestamp::Config for Runtime {373	/// A timestamp: milliseconds since the unix epoch.374	type Moment = u64;375	type OnTimestampSet = ();376	type MinimumPeriod = MinimumPeriod;377	type WeightInfo = ();378}379380parameter_types! {381	// pub const ExistentialDeposit: u128 = 500;382	pub const ExistentialDeposit: u128 = 0;383	pub const MaxLocks: u32 = 50;384}385386impl pallet_balances::Config for Runtime {387	type MaxLocks = MaxLocks;388	type MaxReserves = ();389	type ReserveIdentifier = [u8; 8];390	/// The type for recording an account's balance.391	type Balance = Balance;392	/// The ubiquitous event type.393	type Event = Event;394	type DustRemoval = Treasury;395	type ExistentialDeposit = ExistentialDeposit;396	type AccountStore = System;397	type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;398}399400pub const fn deposit(items: u32, bytes: u32) -> Balance {401	items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE402}403404/*405parameter_types! {406	pub TombstoneDeposit: Balance = deposit(407		1,408		sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,409	);410	pub DepositPerContract: Balance = TombstoneDeposit::get();411	pub const DepositPerStorageByte: Balance = deposit(0, 1);412	pub const DepositPerStorageItem: Balance = deposit(1, 0);413	pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);414	pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;415	pub const SignedClaimHandicap: u32 = 2;416	pub const MaxDepth: u32 = 32;417	pub const MaxValueSize: u32 = 16 * 1024;418	pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb419	// The lazy deletion runs inside on_initialize.420	pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *421		RuntimeBlockWeights::get().max_block;422	// The weight needed for decoding the queue should be less or equal than a fifth423	// of the overall weight dedicated to the lazy deletion.424	pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (425			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -426			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)427		)) / 5) as u32;428	pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();429}430431impl pallet_contracts::Config for Runtime {432	type Time = Timestamp;433	type Randomness = RandomnessCollectiveFlip;434	type Currency = Balances;435	type Event = Event;436	type RentPayment = ();437	type SignedClaimHandicap = SignedClaimHandicap;438	type TombstoneDeposit = TombstoneDeposit;439	type DepositPerContract = DepositPerContract;440	type DepositPerStorageByte = DepositPerStorageByte;441	type DepositPerStorageItem = DepositPerStorageItem;442	type RentFraction = RentFraction;443	type SurchargeReward = SurchargeReward;444	type WeightPrice = pallet_transaction_payment::Pallet<Self>;445	type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;446	type ChainExtension = NFTExtension;447	type DeletionQueueDepth = DeletionQueueDepth;448	type DeletionWeightLimit = DeletionWeightLimit;449	type Schedule = Schedule;450	type CallStack = [pallet_contracts::Frame<Self>; 31];451}452*/453454parameter_types! {455	/// This value increases the priority of `Operational` transactions by adding456	/// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.457	pub const OperationalFeeMultiplier: u8 = 5;458}459460/// Linear implementor of `WeightToFeePolynomial`461pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);462463impl<T> WeightToFeePolynomial for LinearFee<T>464where465	T: BaseArithmetic + From<u32> + Copy + Unsigned,466{467	type Balance = T;468469	fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {470		smallvec!(WeightToFeeCoefficient {471			// Targeting 0.1 Unique per NFT transfer472			coeff_integer: WEIGHT_TO_FEE_COEFF.into(),473			coeff_frac: Perbill::zero(),474			negative: false,475			degree: 1,476		})477	}478}479480impl pallet_transaction_payment::Config for Runtime {481	type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;482	type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;483	type OperationalFeeMultiplier = OperationalFeeMultiplier;484	type WeightToFee = LinearFee<Balance>;485	type FeeMultiplierUpdate = ();486}487488parameter_types! {489	pub const ProposalBond: Permill = Permill::from_percent(5);490	pub const ProposalBondMinimum: Balance = 1 * UNIQUE;491	pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;492	pub const SpendPeriod: BlockNumber = 5 * MINUTES;493	pub const Burn: Permill = Permill::from_percent(0);494	pub const TipCountdown: BlockNumber = 1 * DAYS;495	pub const TipFindersFee: Percent = Percent::from_percent(20);496	pub const TipReportDepositBase: Balance = 1 * UNIQUE;497	pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;498	pub const BountyDepositBase: Balance = 1 * UNIQUE;499	pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;500	pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");501	pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;502	pub const MaximumReasonLength: u32 = 16384;503	pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);504	pub const BountyValueMinimum: Balance = 5 * UNIQUE;505	pub const MaxApprovals: u32 = 100;506}507508impl pallet_treasury::Config for Runtime {509	type PalletId = TreasuryModuleId;510	type Currency = Balances;511	type ApproveOrigin = EnsureRoot<AccountId>;512	type RejectOrigin = EnsureRoot<AccountId>;513	type Event = Event;514	type OnSlash = ();515	type ProposalBond = ProposalBond;516	type ProposalBondMinimum = ProposalBondMinimum;517	type ProposalBondMaximum = ProposalBondMaximum;518	type SpendPeriod = SpendPeriod;519	type Burn = Burn;520	type BurnDestination = ();521	type SpendFunds = ();522	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;523	type MaxApprovals = MaxApprovals;524}525526impl pallet_sudo::Config for Runtime {527	type Event = Event;528	type Call = Call;529}530531pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);532533impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider534	for RelayChainBlockNumberProvider<T>535{536	type BlockNumber = BlockNumber;537538	fn current_block_number() -> Self::BlockNumber {539		cumulus_pallet_parachain_system::Pallet::<T>::validation_data()540			.map(|d| d.relay_parent_number)541			.unwrap_or_default()542	}543}544545parameter_types! {546	pub const MinVestedTransfer: Balance = 10 * UNIQUE;547	pub const MaxVestingSchedules: u32 = 28;548}549550impl orml_vesting::Config for Runtime {551	type Event = Event;552	type Currency = pallet_balances::Pallet<Runtime>;553	type MinVestedTransfer = MinVestedTransfer;554	type VestedTransferOrigin = EnsureSigned<AccountId>;555	type WeightInfo = ();556	type MaxVestingSchedules = MaxVestingSchedules;557	type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;558}559560parameter_types! {561	pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;562	pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;563}564565impl cumulus_pallet_parachain_system::Config for Runtime {566	type Event = Event;567	type SelfParaId = parachain_info::Pallet<Self>;568	type OnSystemEvent = ();569	// type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<570	// 	MaxDownwardMessageWeight,571	// 	XcmExecutor<XcmConfig>,572	// 	Call,573	// >;574	type OutboundXcmpMessageSource = XcmpQueue;575	type DmpMessageHandler = DmpQueue;576	type ReservedDmpWeight = ReservedDmpWeight;577	type ReservedXcmpWeight = ReservedXcmpWeight;578	type XcmpMessageHandler = XcmpQueue;579}580581impl parachain_info::Config for Runtime {}582583impl cumulus_pallet_aura_ext::Config for Runtime {}584585parameter_types! {586	pub const RelayLocation: MultiLocation = MultiLocation::parent();587	pub const RelayNetwork: NetworkId = NetworkId::Polkadot;588	pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();589	pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();590}591592/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used593/// when determining ownership of accounts for asset transacting and when attempting to use XCM594/// `Transact` in order to determine the dispatch Origin.595pub type LocationToAccountId = (596	// The parent (Relay-chain) origin converts to the default `AccountId`.597	ParentIsPreset<AccountId>,598	// Sibling parachain origins convert to AccountId via the `ParaId::into`.599	SiblingParachainConvertsVia<Sibling, AccountId>,600	// Straight up local `AccountId32` origins just alias directly to `AccountId`.601	AccountId32Aliases<RelayNetwork, AccountId>,602);603604pub struct OnlySelfCurrency;605impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {606	fn matches_fungible(a: &MultiAsset) -> Option<B> {607		match (&a.id, &a.fun) {608			(Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),609			_ => None,610		}611	}612}613614/// Means for transacting assets on this chain.615pub type LocalAssetTransactor = CurrencyAdapter<616	// Use this currency:617	Balances,618	// Use this currency when it is a fungible asset matching the given location or name:619	OnlySelfCurrency,620	// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:621	LocationToAccountId,622	// Our chain's account ID type (we can't get away without mentioning it explicitly):623	AccountId,624	// We don't track any teleports.625	(),626>;627628/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,629/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can630/// biases the kind of local `Origin` it will become.631pub type XcmOriginToTransactDispatchOrigin = (632	// Sovereign account converter; this attempts to derive an `AccountId` from the origin location633	// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for634	// foreign chains who want to have a local sovereign account on this chain which they control.635	SovereignSignedViaLocation<LocationToAccountId, Origin>,636	// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when637	// recognised.638	RelayChainAsNative<RelayOrigin, Origin>,639	// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when640	// recognised.641	SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,642	// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a643	// transaction from the Root origin.644	ParentAsSuperuser<Origin>,645	// Native signed account converter; this just converts an `AccountId32` origin into a normal646	// `Origin::Signed` origin of the same 32-byte value.647	SignedAccountId32AsNative<RelayNetwork, Origin>,648	// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.649	XcmPassthrough<Origin>,650);651652parameter_types! {653	// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.654	pub UnitWeightCost: Weight = 1_000_000;655	// 1200 UNIQUEs buy 1 second of weight.656	pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);657	pub const MaxInstructions: u32 = 100;658	pub const MaxAuthorities: u32 = 100_000;659}660661match_types! {662	pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {663		MultiLocation { parents: 1, interior: Here } |664		MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }665	};666}667668pub type Barrier = (669	TakeWeightCredit,670	AllowTopLevelPaidExecutionFrom<Everything>,671	AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,672	// ^^^ Parent & its unit plurality gets free execution673);674675pub struct UsingOnlySelfCurrencyComponents<676	WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,677	AssetId: Get<MultiLocation>,678	AccountId,679	Currency: CurrencyT<AccountId>,680	OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,681>(682	Weight,683	Currency::Balance,684	PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,685);686impl<687		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,688		AssetId: Get<MultiLocation>,689		AccountId,690		Currency: CurrencyT<AccountId>,691		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,692	> WeightTrader693	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>694{695	fn new() -> Self {696		Self(0, Zero::zero(), PhantomData)697	}698699	fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {700		let amount = WeightToFee::calc(&weight);701		let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;702703		// location to this parachain through relay chain704		let option1: xcm::v1::AssetId = Concrete(MultiLocation {705			parents: 1,706			interior: X1(Parachain(ParachainInfo::parachain_id().into())),707		});708		// direct location709		let option2: xcm::v1::AssetId = Concrete(MultiLocation {710			parents: 0,711			interior: Here,712		});713714		let required = if payment.fungible.contains_key(&option1) {715			(option1, u128_amount).into()716		} else if payment.fungible.contains_key(&option2) {717			(option2, u128_amount).into()718		} else {719			(Concrete(MultiLocation::default()), u128_amount).into()720		};721722		let unused = payment723			.checked_sub(required)724			.map_err(|_| XcmError::TooExpensive)?;725		self.0 = self.0.saturating_add(weight);726		self.1 = self.1.saturating_add(amount);727		Ok(unused)728	}729730	fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {731		let weight = weight.min(self.0);732		let amount = WeightToFee::calc(&weight);733		self.0 -= weight;734		self.1 = self.1.saturating_sub(amount);735		let amount: u128 = amount.saturated_into();736		if amount > 0 {737			Some((AssetId::get(), amount).into())738		} else {739			None740		}741	}742}743impl<744		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,745		AssetId: Get<MultiLocation>,746		AccountId,747		Currency: CurrencyT<AccountId>,748		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,749	> Drop750	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>751{752	fn drop(&mut self) {753		OnUnbalanced::on_unbalanced(Currency::issue(self.1));754	}755}756757pub struct XcmConfig;758impl Config for XcmConfig {759	type Call = Call;760	type XcmSender = XcmRouter;761	// How to withdraw and deposit an asset.762	type AssetTransactor = LocalAssetTransactor;763	type OriginConverter = XcmOriginToTransactDispatchOrigin;764	type IsReserve = NativeAsset;765	type IsTeleporter = (); // Teleportation is disabled766	type LocationInverter = LocationInverter<Ancestry>;767	type Barrier = Barrier;768	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;769	type Trader = UsingOnlySelfCurrencyComponents<770		IdentityFee<Balance>,771		RelayLocation,772		AccountId,773		Balances,774		(),775	>;776	type ResponseHandler = (); // Don't handle responses for now.777	type SubscriptionService = PolkadotXcm;778779	type AssetTrap = PolkadotXcm;780	type AssetClaims = PolkadotXcm;781}782783// parameter_types! {784// 	pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;785// }786787/// No local origins on this chain are allowed to dispatch XCM sends/executions.788pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);789790/// The means for routing XCM messages which are not for local execution into the right message791/// queues.792pub type XcmRouter = (793	// Two routers - use UMP to communicate with the relay chain:794	cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,795	// ..and XCMP to communicate with the sibling chains.796	XcmpQueue,797);798799impl pallet_evm_coder_substrate::Config for Runtime {800	type GasWeightMapping = FixedGasWeightMapping;801}802803impl pallet_xcm::Config for Runtime {804	type Event = Event;805	type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;806	type XcmRouter = XcmRouter;807	type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;808	type XcmExecuteFilter = Everything;809	type XcmExecutor = XcmExecutor<XcmConfig>;810	type XcmTeleportFilter = Everything;811	type XcmReserveTransferFilter = Everything;812	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;813	type LocationInverter = LocationInverter<Ancestry>;814	type Origin = Origin;815	type Call = Call;816	const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;817	type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;818}819820impl cumulus_pallet_xcm::Config for Runtime {821	type Event = Event;822	type XcmExecutor = XcmExecutor<XcmConfig>;823}824825impl cumulus_pallet_xcmp_queue::Config for Runtime {826	type WeightInfo = ();827	type Event = Event;828	type XcmExecutor = XcmExecutor<XcmConfig>;829	type ChannelInfo = ParachainSystem;830	type VersionWrapper = ();831	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;832	type ControllerOrigin = EnsureRoot<AccountId>;833	type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;834}835836impl cumulus_pallet_dmp_queue::Config for Runtime {837	type Event = Event;838	type XcmExecutor = XcmExecutor<XcmConfig>;839	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;840}841842impl pallet_aura::Config for Runtime {843	type AuthorityId = AuraId;844	type DisabledValidators = ();845	type MaxAuthorities = MaxAuthorities;846}847848parameter_types! {849	pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();850	pub const CollectionCreationPrice: Balance = 2 * UNIQUE;851}852853impl pallet_common::Config for Runtime {854	type WeightInfo = pallet_common::weights::SubstrateWeight<Self>;855	type Event = Event;856	type Currency = Balances;857	type CollectionCreationPrice = CollectionCreationPrice;858	type TreasuryAccountId = TreasuryAccountId;859	type CollectionDispatch = CollectionDispatchT<Self>;860861	type EvmTokenAddressMapping = EvmTokenAddressMapping;862	type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;863}864865impl pallet_structure::Config for Runtime {866	type Event = Event;867	type Call = Call;868	type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;869}870871impl pallet_evm::account::Config for Runtime {872	type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;873	type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;874	type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;875}876877impl pallet_fungible::Config for Runtime {878	type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;879}880impl pallet_refungible::Config for Runtime {881	type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;882}883impl pallet_nonfungible::Config for Runtime {884	type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;885}886887impl pallet_proxy_rmrk_core::Config for Runtime {888	type Event = Event;889}890891impl pallet_proxy_rmrk_equip::Config for Runtime {892	type Event = Event;893}894895impl pallet_unique::Config for Runtime {896	type Event = Event;897	type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;898	type CommonWeightInfo = CommonWeights<Self>;899}900901parameter_types! {902	pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied903}904905/// Used for the pallet inflation906impl pallet_inflation::Config for Runtime {907	type Currency = Balances;908	type TreasuryAccountId = TreasuryAccountId;909	type InflationBlockInterval = InflationBlockInterval;910	type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;911}912913// parameter_types! {914// 	pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *915// 		RuntimeBlockWeights::get().max_block;916// 	pub const MaxScheduledPerBlock: u32 = 50;917// }918919type EvmSponsorshipHandler = (920	UniqueEthSponsorshipHandler<Runtime>,921	pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,922);923type SponsorshipHandler = (924	UniqueSponsorshipHandler<Runtime>,925	//pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,926	pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,927);928929// impl pallet_unq_scheduler::Config for Runtime {930// 	type Event = Event;931// 	type Origin = Origin;932// 	type PalletsOrigin = OriginCaller;933// 	type Call = Call;934// 	type MaximumWeight = MaximumSchedulerWeight;935// 	type ScheduleOrigin = EnsureSigned<AccountId>;936// 	type MaxScheduledPerBlock = MaxScheduledPerBlock;937// 	type SponsorshipHandler = SponsorshipHandler;938// 	type WeightInfo = ();939// }940941impl pallet_evm_transaction_payment::Config for Runtime {942	type EvmSponsorshipHandler = EvmSponsorshipHandler;943	type Currency = Balances;944}945946impl pallet_charge_transaction::Config for Runtime {947	type SponsorshipHandler = SponsorshipHandler;948}949950// impl pallet_contract_helpers::Config for Runtime {951//	 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;952// }953954parameter_types! {955	// 0x842899ECF380553E8a4de75bF534cdf6fBF64049956	pub const HelpersContractAddress: H160 = H160([957		0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,958	]);959}960961impl pallet_evm_contract_helpers::Config for Runtime {962	type ContractAddress = HelpersContractAddress;963	type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;964}965966construct_runtime!(967	pub enum Runtime where968		Block = Block,969		NodeBlock = opaque::Block,970		UncheckedExtrinsic = UncheckedExtrinsic971	{972		ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,973		ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,974975		Aura: pallet_aura::{Pallet, Config<T>} = 22,976		AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,977978		Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,979		RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,980		Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,981		TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,982		Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,983		Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,984		System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,985		Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,986		// Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,987		// Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,988989		// XCM helpers.990		XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,991		PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,992		CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,993		DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,994995		// Unique Pallets996		Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,997		Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,998		// Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,999		// free = 631000		Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,1001		// ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,1002		Common: pallet_common::{Pallet, Storage, Event<T>} = 66,1003		Fungible: pallet_fungible::{Pallet, Storage} = 67,1004		Refungible: pallet_refungible::{Pallet, Storage} = 68,1005		Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1006		Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1007		RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,1008		RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,10091010		// Frontier1011		EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1012		Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,10131014		EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1015		EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1016		EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1017		EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1018	}1019);10201021pub struct TransactionConverter;10221023impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1024	fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1025		UncheckedExtrinsic::new_unsigned(1026			pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1027		)1028	}1029}10301031impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1032	fn convert_transaction(1033		&self,1034		transaction: pallet_ethereum::Transaction,1035	) -> opaque::UncheckedExtrinsic {1036		let extrinsic = UncheckedExtrinsic::new_unsigned(1037			pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1038		);1039		let encoded = extrinsic.encode();1040		opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1041			.expect("Encoded extrinsic is always valid")1042	}1043}10441045/// The address format for describing accounts.1046pub type Address = sp_runtime::MultiAddress<AccountId, ()>;1047/// Block header type as expected by this runtime.1048pub type Header = generic::Header<BlockNumber, BlakeTwo256>;1049/// Block type as expected by this runtime.1050pub type Block = generic::Block<Header, UncheckedExtrinsic>;1051/// A Block signed with a Justification1052pub type SignedBlock = generic::SignedBlock<Block>;1053/// BlockId type as expected by this runtime.1054pub type BlockId = generic::BlockId<Block>;1055/// The SignedExtension to the basic transaction logic.1056pub type SignedExtra = (1057	frame_system::CheckSpecVersion<Runtime>,1058	// system::CheckTxVersion<Runtime>,1059	frame_system::CheckGenesis<Runtime>,1060	frame_system::CheckEra<Runtime>,1061	frame_system::CheckNonce<Runtime>,1062	frame_system::CheckWeight<Runtime>,1063	pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1064	//pallet_contract_helpers::ContractHelpersExtension<Runtime>,1065	pallet_ethereum::FakeTransactionFinalizer<Runtime>,1066);1067/// Unchecked extrinsic type as expected by this runtime.1068pub type UncheckedExtrinsic =1069	fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;1070/// Extrinsic type that has already been checked.1071pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;1072/// Executive: handles dispatch to the various modules.1073pub type Executive = frame_executive::Executive<1074	Runtime,1075	Block,1076	frame_system::ChainContext<Runtime>,1077	Runtime,1078	AllPalletsReversedWithSystemFirst,1079>;10801081impl_opaque_keys! {1082	pub struct SessionKeys {1083		pub aura: Aura,1084	}1085}10861087impl fp_self_contained::SelfContainedCall for Call {1088	type SignedInfo = H160;10891090	fn is_self_contained(&self) -> bool {1091		match self {1092			Call::Ethereum(call) => call.is_self_contained(),1093			_ => false,1094		}1095	}10961097	fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1098		match self {1099			Call::Ethereum(call) => call.check_self_contained(),1100			_ => None,1101		}1102	}11031104	fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1105		match self {1106			Call::Ethereum(call) => call.validate_self_contained(info),1107			_ => None,1108		}1109	}11101111	fn pre_dispatch_self_contained(1112		&self,1113		info: &Self::SignedInfo,1114	) -> Option<Result<(), TransactionValidityError>> {1115		match self {1116			Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1117			_ => None,1118		}1119	}11201121	fn apply_self_contained(1122		self,1123		info: Self::SignedInfo,1124	) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1125		match self {1126			call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1127				Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1128			)),1129			_ => None,1130		}1131	}1132}11331134macro_rules! dispatch_unique_runtime {1135	($collection:ident.$method:ident($($name:ident),*)) => {{1136		let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1137		let dispatch = collection.as_dyn();11381139		Ok::<_, DispatchError>(dispatch.$method($($name),*))1140	}};1141}11421143impl_common_runtime_apis!();11441145struct CheckInherents;11461147impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1148	fn check_inherents(1149		block: &Block,1150		relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1151	) -> sp_inherents::CheckInherentsResult {1152		let relay_chain_slot = relay_state_proof1153			.read_slot()1154			.expect("Could not read the relay chain slot from the proof");11551156		let inherent_data =1157			cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1158				relay_chain_slot,1159				sp_std::time::Duration::from_secs(6),1160			)1161			.create_inherent_data()1162			.expect("Could not create the timestamp inherent data");11631164		inherent_data.check_extrinsics(block)1165	}1166}11671168cumulus_pallet_parachain_system::register_validate_block!(1169	Runtime = Runtime,1170	BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1171	CheckInherents = CheckInherents,1172);
after · runtime/unique/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//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.1819#![cfg_attr(not(feature = "std"), no_std)]20// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.21#![recursion_limit = "1024"]22#![allow(clippy::from_over_into, clippy::identity_op)]23#![allow(clippy::fn_to_numeric_cast_with_truncation)]24// Make the WASM binary available.25#[cfg(feature = "std")]26include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));2728use sp_api::impl_runtime_apis;29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};30use sp_runtime::DispatchError;31// #[cfg(any(feature = "std", test))]32// pub use sp_runtime::BuildStorage;3334use sp_runtime::{35	Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,36	traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion, Zero},37	transaction_validity::{TransactionSource, TransactionValidity},38	ApplyExtrinsicResult, RuntimeAppPublic,39};4041use sp_std::prelude::*;4243#[cfg(feature = "std")]44use sp_version::NativeVersion;45use sp_version::RuntimeVersion;46pub use pallet_transaction_payment::{47	Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,48};49// A few exports that help ease life for downstream crates.50pub use pallet_balances::Call as BalancesCall;51pub use pallet_evm::{52	EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _, OnMethodCall,53};54pub use frame_support::{55	construct_runtime, match_types,56	dispatch::DispatchResult,57	PalletId, parameter_types, StorageValue, ConsensusEngineId,58	traits::{59		tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,60		Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,61		OnUnbalanced, Randomness, FindAuthor, ConstU32, Imbalance,62	},63	weights::{64		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},65		DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,66		WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,67	},68};69use unique_runtime_common::{70	dispatch::{CollectionDispatchT, CollectionDispatch},71	weights::CommonWeights,72	sponsoring::UniqueSponsorshipHandler,73	eth_sponsoring::UniqueEthSponsorshipHandler,74};75use up_data_structs::*;76// use pallet_contracts::weights::WeightInfo;77// #[cfg(any(feature = "std", test))]78use frame_system::{79	self as frame_system, EnsureRoot, EnsureSigned,80	limits::{BlockWeights, BlockLength},81};82use sp_arithmetic::{83	traits::{BaseArithmetic, Unsigned},84};85use smallvec::smallvec;86use codec::{Encode, Decode};87use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping};88use fp_rpc::TransactionStatus;89use sp_runtime::{90	traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},91	transaction_validity::TransactionValidityError,92	SaturatedConversion,93};9495// pub use pallet_timestamp::Call as TimestampCall;9697// Polkadot imports98use pallet_xcm::XcmPassthrough;99use polkadot_parachain::primitives::Sibling;100use up_data_structs::mapping::{CrossTokenAddressMapping, EvmTokenAddressMapping};101use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};102use xcm_builder::{103	AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,104	EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,105	RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,106	SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,107	ParentIsPreset,108};109use xcm_executor::{Config, XcmExecutor, Assets};110use sp_std::{marker::PhantomData};111112use xcm::latest::{113	//	Xcm,114	AssetId::{Concrete},115	Fungibility::Fungible as XcmFungible,116	MultiAsset,117	Error as XcmError,118};119use xcm_executor::traits::{MatchesFungible, WeightTrader};120//use xcm_executor::traits::MatchesFungible;121use sp_runtime::traits::CheckedConversion;122123use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};124125pub const RUNTIME_NAME: &str = "unique";126pub const TOKEN_SYMBOL: &str = "UNQ";127128type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;129130impl RuntimeInstance for Runtime {131	type CrossAccountId = self::CrossAccountId;132133	type TransactionConverter = self::TransactionConverter;134135	fn get_transaction_converter() -> TransactionConverter {136		TransactionConverter137	}138}139140/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know141/// the specifics of the runtime. They can then be made to be agnostic over specific formats142/// of data like extrinsics, allowing for them to continue syncing the network through upgrades143/// to even the core data structures.144pub mod opaque {145	use sp_std::prelude::*;146	use sp_runtime::impl_opaque_keys;147	use super::Aura;148149	pub use unique_runtime_common::types::*;150151	impl_opaque_keys! {152		pub struct SessionKeys {153			pub aura: Aura,154		}155	}156}157158/// This runtime version.159pub const VERSION: RuntimeVersion = RuntimeVersion {160	spec_name: create_runtime_str!(RUNTIME_NAME),161	impl_name: create_runtime_str!(RUNTIME_NAME),162	authoring_version: 1,163	spec_version: 920000,164	impl_version: 0,165	apis: RUNTIME_API_VERSIONS,166	transaction_version: 1,167	state_version: 0,168};169170#[derive(codec::Encode, codec::Decode)]171pub enum XCMPMessage<XAccountId, XBalance> {172	/// Transfer tokens to the given account from the Parachain account.173	TransferToken(XAccountId, XBalance),174}175176/// The version information used to identify this runtime when compiled natively.177#[cfg(feature = "std")]178pub fn native_version() -> NativeVersion {179	NativeVersion {180		runtime_version: VERSION,181		can_author_with: Default::default(),182	}183}184185type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;186187pub struct DealWithFees;188impl OnUnbalanced<NegativeImbalance> for DealWithFees {189	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {190		if let Some(fees) = fees_then_tips.next() {191			// for fees, 100% to treasury192			let mut split = fees.ration(100, 0);193			if let Some(tips) = fees_then_tips.next() {194				// for tips, if any, 100% to treasury195				tips.ration_merge_into(100, 0, &mut split);196			}197			Treasury::on_unbalanced(split.0);198			// Author::on_unbalanced(split.1);199		}200	}201}202203parameter_types! {204	pub const BlockHashCount: BlockNumber = 2400;205	pub RuntimeBlockLength: BlockLength =206		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);207	pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);208	pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;209	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()210		.base_block(BlockExecutionWeight::get())211		.for_class(DispatchClass::all(), |weights| {212			weights.base_extrinsic = ExtrinsicBaseWeight::get();213		})214		.for_class(DispatchClass::Normal, |weights| {215			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);216		})217		.for_class(DispatchClass::Operational, |weights| {218			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);219			// Operational transactions have some extra reserved space, so that they220			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.221			weights.reserved = Some(222				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT223			);224		})225		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)226		.build_or_panic();227	pub const Version: RuntimeVersion = VERSION;228	pub const SS58Prefix: u16 = 7391;229}230231parameter_types! {232	pub const ChainId: u64 = 8880;233}234235pub struct FixedFee;236impl FeeCalculator for FixedFee {237	fn min_gas_price() -> U256 {238		MIN_GAS_PRICE.into()239	}240}241242// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case243// (contract, which only writes a lot of data),244// approximating on top of our real store write weight245parameter_types! {246	pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;247	pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;248	pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();249}250251/// Limiting EVM execution to 50% of block for substrate users and management tasks252/// EVM transaction consumes more weight than substrate's, so we can't rely on them being253/// scheduled fairly254const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);255parameter_types! {256	pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());257}258259pub enum FixedGasWeightMapping {}260impl GasWeightMapping for FixedGasWeightMapping {261	fn gas_to_weight(gas: u64) -> Weight {262		gas.saturating_mul(WeightPerGas::get())263	}264	fn weight_to_gas(weight: Weight) -> u64 {265		weight / WeightPerGas::get()266	}267}268269impl pallet_evm::Config for Runtime {270	type BlockGasLimit = BlockGasLimit;271	type FeeCalculator = FixedFee;272	type GasWeightMapping = FixedGasWeightMapping;273	type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;274	type CallOrigin = EnsureAddressTruncated<Self>;275	type WithdrawOrigin = EnsureAddressTruncated<Self>;276	type AddressMapping = HashedAddressMapping<Self::Hashing>;277	type PrecompilesType = ();278	type PrecompilesValue = ();279	type Currency = Balances;280	type Event = Event;281	type OnMethodCall = (282		pallet_evm_migration::OnMethodCall<Self>,283		pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,284		CollectionDispatchT<Self>,285		pallet_evm_collection::CollectionOnMethodCall<Self>,286	);287	type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;288	type ChainId = ChainId;289	type Runner = pallet_evm::runner::stack::Runner<Self>;290	type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;291	type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;292	type FindAuthor = EthereumFindAuthor<Aura>;293}294295impl pallet_evm_migration::Config for Runtime {296	type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;297}298299pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);300impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {301	fn find_author<'a, I>(digests: I) -> Option<H160>302	where303		I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,304	{305		if let Some(author_index) = F::find_author(digests) {306			let authority_id = Aura::authorities()[author_index as usize].clone();307			return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));308		}309		None310	}311}312313impl pallet_ethereum::Config for Runtime {314	type Event = Event;315	type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;316}317318impl pallet_randomness_collective_flip::Config for Runtime {}319320impl frame_system::Config for Runtime {321	/// The data to be stored in an account.322	type AccountData = pallet_balances::AccountData<Balance>;323	/// The identifier used to distinguish between accounts.324	type AccountId = AccountId;325	/// The basic call filter to use in dispatchable.326	type BaseCallFilter = Everything;327	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).328	type BlockHashCount = BlockHashCount;329	/// The maximum length of a block (in bytes).330	type BlockLength = RuntimeBlockLength;331	/// The index type for blocks.332	type BlockNumber = BlockNumber;333	/// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.334	type BlockWeights = RuntimeBlockWeights;335	/// The aggregated dispatch type that is available for extrinsics.336	type Call = Call;337	/// The weight of database operations that the runtime can invoke.338	type DbWeight = RocksDbWeight;339	/// The ubiquitous event type.340	type Event = Event;341	/// The type for hashing blocks and tries.342	type Hash = Hash;343	/// The hashing algorithm used.344	type Hashing = BlakeTwo256;345	/// The header type.346	type Header = generic::Header<BlockNumber, BlakeTwo256>;347	/// The index type for storing how many extrinsics an account has signed.348	type Index = Index;349	/// The lookup mechanism to get account ID from whatever is passed in dispatchers.350	type Lookup = AccountIdLookup<AccountId, ()>;351	/// What to do if an account is fully reaped from the system.352	type OnKilledAccount = ();353	/// What to do if a new account is created.354	type OnNewAccount = ();355	type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;356	/// The ubiquitous origin type.357	type Origin = Origin;358	/// This type is being generated by `construct_runtime!`.359	type PalletInfo = PalletInfo;360	/// This is used as an identifier of the chain. 42 is the generic substrate prefix.361	type SS58Prefix = SS58Prefix;362	/// Weight information for the extrinsics of this pallet.363	type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;364	/// Version of the runtime.365	type Version = Version;366	type MaxConsumers = ConstU32<16>;367}368369parameter_types! {370	pub const MinimumPeriod: u64 = SLOT_DURATION / 2;371}372373impl pallet_timestamp::Config for Runtime {374	/// A timestamp: milliseconds since the unix epoch.375	type Moment = u64;376	type OnTimestampSet = ();377	type MinimumPeriod = MinimumPeriod;378	type WeightInfo = ();379}380381parameter_types! {382	// pub const ExistentialDeposit: u128 = 500;383	pub const ExistentialDeposit: u128 = 0;384	pub const MaxLocks: u32 = 50;385}386387impl pallet_balances::Config for Runtime {388	type MaxLocks = MaxLocks;389	type MaxReserves = ();390	type ReserveIdentifier = [u8; 8];391	/// The type for recording an account's balance.392	type Balance = Balance;393	/// The ubiquitous event type.394	type Event = Event;395	type DustRemoval = Treasury;396	type ExistentialDeposit = ExistentialDeposit;397	type AccountStore = System;398	type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;399}400401pub const fn deposit(items: u32, bytes: u32) -> Balance {402	items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE403}404405/*406parameter_types! {407	pub TombstoneDeposit: Balance = deposit(408		1,409		sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,410	);411	pub DepositPerContract: Balance = TombstoneDeposit::get();412	pub const DepositPerStorageByte: Balance = deposit(0, 1);413	pub const DepositPerStorageItem: Balance = deposit(1, 0);414	pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);415	pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;416	pub const SignedClaimHandicap: u32 = 2;417	pub const MaxDepth: u32 = 32;418	pub const MaxValueSize: u32 = 16 * 1024;419	pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb420	// The lazy deletion runs inside on_initialize.421	pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *422		RuntimeBlockWeights::get().max_block;423	// The weight needed for decoding the queue should be less or equal than a fifth424	// of the overall weight dedicated to the lazy deletion.425	pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (426			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -427			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)428		)) / 5) as u32;429	pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();430}431432impl pallet_contracts::Config for Runtime {433	type Time = Timestamp;434	type Randomness = RandomnessCollectiveFlip;435	type Currency = Balances;436	type Event = Event;437	type RentPayment = ();438	type SignedClaimHandicap = SignedClaimHandicap;439	type TombstoneDeposit = TombstoneDeposit;440	type DepositPerContract = DepositPerContract;441	type DepositPerStorageByte = DepositPerStorageByte;442	type DepositPerStorageItem = DepositPerStorageItem;443	type RentFraction = RentFraction;444	type SurchargeReward = SurchargeReward;445	type WeightPrice = pallet_transaction_payment::Pallet<Self>;446	type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;447	type ChainExtension = NFTExtension;448	type DeletionQueueDepth = DeletionQueueDepth;449	type DeletionWeightLimit = DeletionWeightLimit;450	type Schedule = Schedule;451	type CallStack = [pallet_contracts::Frame<Self>; 31];452}453*/454455parameter_types! {456	/// This value increases the priority of `Operational` transactions by adding457	/// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.458	pub const OperationalFeeMultiplier: u8 = 5;459}460461/// Linear implementor of `WeightToFeePolynomial`462pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);463464impl<T> WeightToFeePolynomial for LinearFee<T>465where466	T: BaseArithmetic + From<u32> + Copy + Unsigned,467{468	type Balance = T;469470	fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {471		smallvec!(WeightToFeeCoefficient {472			// Targeting 0.1 Unique per NFT transfer473			coeff_integer: WEIGHT_TO_FEE_COEFF.into(),474			coeff_frac: Perbill::zero(),475			negative: false,476			degree: 1,477		})478	}479}480481impl pallet_transaction_payment::Config for Runtime {482	type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;483	type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;484	type OperationalFeeMultiplier = OperationalFeeMultiplier;485	type WeightToFee = LinearFee<Balance>;486	type FeeMultiplierUpdate = ();487}488489parameter_types! {490	pub const ProposalBond: Permill = Permill::from_percent(5);491	pub const ProposalBondMinimum: Balance = 1 * UNIQUE;492	pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;493	pub const SpendPeriod: BlockNumber = 5 * MINUTES;494	pub const Burn: Permill = Permill::from_percent(0);495	pub const TipCountdown: BlockNumber = 1 * DAYS;496	pub const TipFindersFee: Percent = Percent::from_percent(20);497	pub const TipReportDepositBase: Balance = 1 * UNIQUE;498	pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;499	pub const BountyDepositBase: Balance = 1 * UNIQUE;500	pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;501	pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");502	pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;503	pub const MaximumReasonLength: u32 = 16384;504	pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);505	pub const BountyValueMinimum: Balance = 5 * UNIQUE;506	pub const MaxApprovals: u32 = 100;507}508509impl pallet_treasury::Config for Runtime {510	type PalletId = TreasuryModuleId;511	type Currency = Balances;512	type ApproveOrigin = EnsureRoot<AccountId>;513	type RejectOrigin = EnsureRoot<AccountId>;514	type Event = Event;515	type OnSlash = ();516	type ProposalBond = ProposalBond;517	type ProposalBondMinimum = ProposalBondMinimum;518	type ProposalBondMaximum = ProposalBondMaximum;519	type SpendPeriod = SpendPeriod;520	type Burn = Burn;521	type BurnDestination = ();522	type SpendFunds = ();523	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;524	type MaxApprovals = MaxApprovals;525}526527impl pallet_sudo::Config for Runtime {528	type Event = Event;529	type Call = Call;530}531532pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);533534impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider535	for RelayChainBlockNumberProvider<T>536{537	type BlockNumber = BlockNumber;538539	fn current_block_number() -> Self::BlockNumber {540		cumulus_pallet_parachain_system::Pallet::<T>::validation_data()541			.map(|d| d.relay_parent_number)542			.unwrap_or_default()543	}544}545546parameter_types! {547	pub const MinVestedTransfer: Balance = 10 * UNIQUE;548	pub const MaxVestingSchedules: u32 = 28;549}550551impl orml_vesting::Config for Runtime {552	type Event = Event;553	type Currency = pallet_balances::Pallet<Runtime>;554	type MinVestedTransfer = MinVestedTransfer;555	type VestedTransferOrigin = EnsureSigned<AccountId>;556	type WeightInfo = ();557	type MaxVestingSchedules = MaxVestingSchedules;558	type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;559}560561parameter_types! {562	pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;563	pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;564}565566impl cumulus_pallet_parachain_system::Config for Runtime {567	type Event = Event;568	type SelfParaId = parachain_info::Pallet<Self>;569	type OnSystemEvent = ();570	// type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<571	// 	MaxDownwardMessageWeight,572	// 	XcmExecutor<XcmConfig>,573	// 	Call,574	// >;575	type OutboundXcmpMessageSource = XcmpQueue;576	type DmpMessageHandler = DmpQueue;577	type ReservedDmpWeight = ReservedDmpWeight;578	type ReservedXcmpWeight = ReservedXcmpWeight;579	type XcmpMessageHandler = XcmpQueue;580}581582impl parachain_info::Config for Runtime {}583584impl cumulus_pallet_aura_ext::Config for Runtime {}585586parameter_types! {587	pub const RelayLocation: MultiLocation = MultiLocation::parent();588	pub const RelayNetwork: NetworkId = NetworkId::Polkadot;589	pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();590	pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();591}592593/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used594/// when determining ownership of accounts for asset transacting and when attempting to use XCM595/// `Transact` in order to determine the dispatch Origin.596pub type LocationToAccountId = (597	// The parent (Relay-chain) origin converts to the default `AccountId`.598	ParentIsPreset<AccountId>,599	// Sibling parachain origins convert to AccountId via the `ParaId::into`.600	SiblingParachainConvertsVia<Sibling, AccountId>,601	// Straight up local `AccountId32` origins just alias directly to `AccountId`.602	AccountId32Aliases<RelayNetwork, AccountId>,603);604605pub struct OnlySelfCurrency;606impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {607	fn matches_fungible(a: &MultiAsset) -> Option<B> {608		match (&a.id, &a.fun) {609			(Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),610			_ => None,611		}612	}613}614615/// Means for transacting assets on this chain.616pub type LocalAssetTransactor = CurrencyAdapter<617	// Use this currency:618	Balances,619	// Use this currency when it is a fungible asset matching the given location or name:620	OnlySelfCurrency,621	// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:622	LocationToAccountId,623	// Our chain's account ID type (we can't get away without mentioning it explicitly):624	AccountId,625	// We don't track any teleports.626	(),627>;628629/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,630/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can631/// biases the kind of local `Origin` it will become.632pub type XcmOriginToTransactDispatchOrigin = (633	// Sovereign account converter; this attempts to derive an `AccountId` from the origin location634	// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for635	// foreign chains who want to have a local sovereign account on this chain which they control.636	SovereignSignedViaLocation<LocationToAccountId, Origin>,637	// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when638	// recognised.639	RelayChainAsNative<RelayOrigin, Origin>,640	// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when641	// recognised.642	SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,643	// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a644	// transaction from the Root origin.645	ParentAsSuperuser<Origin>,646	// Native signed account converter; this just converts an `AccountId32` origin into a normal647	// `Origin::Signed` origin of the same 32-byte value.648	SignedAccountId32AsNative<RelayNetwork, Origin>,649	// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.650	XcmPassthrough<Origin>,651);652653parameter_types! {654	// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.655	pub UnitWeightCost: Weight = 1_000_000;656	// 1200 UNIQUEs buy 1 second of weight.657	pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);658	pub const MaxInstructions: u32 = 100;659	pub const MaxAuthorities: u32 = 100_000;660}661662match_types! {663	pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {664		MultiLocation { parents: 1, interior: Here } |665		MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }666	};667}668669pub type Barrier = (670	TakeWeightCredit,671	AllowTopLevelPaidExecutionFrom<Everything>,672	AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,673	// ^^^ Parent & its unit plurality gets free execution674);675676pub struct UsingOnlySelfCurrencyComponents<677	WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,678	AssetId: Get<MultiLocation>,679	AccountId,680	Currency: CurrencyT<AccountId>,681	OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,682>(683	Weight,684	Currency::Balance,685	PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,686);687impl<688		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,689		AssetId: Get<MultiLocation>,690		AccountId,691		Currency: CurrencyT<AccountId>,692		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,693	> WeightTrader694	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>695{696	fn new() -> Self {697		Self(0, Zero::zero(), PhantomData)698	}699700	fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {701		let amount = WeightToFee::calc(&weight);702		let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;703704		// location to this parachain through relay chain705		let option1: xcm::v1::AssetId = Concrete(MultiLocation {706			parents: 1,707			interior: X1(Parachain(ParachainInfo::parachain_id().into())),708		});709		// direct location710		let option2: xcm::v1::AssetId = Concrete(MultiLocation {711			parents: 0,712			interior: Here,713		});714715		let required = if payment.fungible.contains_key(&option1) {716			(option1, u128_amount).into()717		} else if payment.fungible.contains_key(&option2) {718			(option2, u128_amount).into()719		} else {720			(Concrete(MultiLocation::default()), u128_amount).into()721		};722723		let unused = payment724			.checked_sub(required)725			.map_err(|_| XcmError::TooExpensive)?;726		self.0 = self.0.saturating_add(weight);727		self.1 = self.1.saturating_add(amount);728		Ok(unused)729	}730731	fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {732		let weight = weight.min(self.0);733		let amount = WeightToFee::calc(&weight);734		self.0 -= weight;735		self.1 = self.1.saturating_sub(amount);736		let amount: u128 = amount.saturated_into();737		if amount > 0 {738			Some((AssetId::get(), amount).into())739		} else {740			None741		}742	}743}744impl<745		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,746		AssetId: Get<MultiLocation>,747		AccountId,748		Currency: CurrencyT<AccountId>,749		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,750	> Drop751	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>752{753	fn drop(&mut self) {754		OnUnbalanced::on_unbalanced(Currency::issue(self.1));755	}756}757758pub struct XcmConfig;759impl Config for XcmConfig {760	type Call = Call;761	type XcmSender = XcmRouter;762	// How to withdraw and deposit an asset.763	type AssetTransactor = LocalAssetTransactor;764	type OriginConverter = XcmOriginToTransactDispatchOrigin;765	type IsReserve = NativeAsset;766	type IsTeleporter = (); // Teleportation is disabled767	type LocationInverter = LocationInverter<Ancestry>;768	type Barrier = Barrier;769	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;770	type Trader = UsingOnlySelfCurrencyComponents<771		IdentityFee<Balance>,772		RelayLocation,773		AccountId,774		Balances,775		(),776	>;777	type ResponseHandler = (); // Don't handle responses for now.778	type SubscriptionService = PolkadotXcm;779780	type AssetTrap = PolkadotXcm;781	type AssetClaims = PolkadotXcm;782}783784// parameter_types! {785// 	pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;786// }787788/// No local origins on this chain are allowed to dispatch XCM sends/executions.789pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);790791/// The means for routing XCM messages which are not for local execution into the right message792/// queues.793pub type XcmRouter = (794	// Two routers - use UMP to communicate with the relay chain:795	cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,796	// ..and XCMP to communicate with the sibling chains.797	XcmpQueue,798);799800impl pallet_evm_coder_substrate::Config for Runtime {801	type GasWeightMapping = FixedGasWeightMapping;802}803804impl pallet_xcm::Config for Runtime {805	type Event = Event;806	type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;807	type XcmRouter = XcmRouter;808	type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;809	type XcmExecuteFilter = Everything;810	type XcmExecutor = XcmExecutor<XcmConfig>;811	type XcmTeleportFilter = Everything;812	type XcmReserveTransferFilter = Everything;813	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;814	type LocationInverter = LocationInverter<Ancestry>;815	type Origin = Origin;816	type Call = Call;817	const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;818	type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;819}820821impl cumulus_pallet_xcm::Config for Runtime {822	type Event = Event;823	type XcmExecutor = XcmExecutor<XcmConfig>;824}825826impl cumulus_pallet_xcmp_queue::Config for Runtime {827	type WeightInfo = ();828	type Event = Event;829	type XcmExecutor = XcmExecutor<XcmConfig>;830	type ChannelInfo = ParachainSystem;831	type VersionWrapper = ();832	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;833	type ControllerOrigin = EnsureRoot<AccountId>;834	type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;835}836837impl cumulus_pallet_dmp_queue::Config for Runtime {838	type Event = Event;839	type XcmExecutor = XcmExecutor<XcmConfig>;840	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;841}842843impl pallet_aura::Config for Runtime {844	type AuthorityId = AuraId;845	type DisabledValidators = ();846	type MaxAuthorities = MaxAuthorities;847}848849parameter_types! {850	pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();851	pub const CollectionCreationPrice: Balance = 2 * UNIQUE;852}853854impl pallet_common::Config for Runtime {855	type WeightInfo = pallet_common::weights::SubstrateWeight<Self>;856	type Event = Event;857	type Currency = Balances;858	type CollectionCreationPrice = CollectionCreationPrice;859	type TreasuryAccountId = TreasuryAccountId;860	type CollectionDispatch = CollectionDispatchT<Self>;861862	type EvmTokenAddressMapping = EvmTokenAddressMapping;863	type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;864}865866impl pallet_structure::Config for Runtime {867	type Event = Event;868	type Call = Call;869	type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;870}871872impl pallet_evm::account::Config for Runtime {873	type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;874	type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;875	type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;876}877878impl pallet_fungible::Config for Runtime {879	type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;880}881impl pallet_refungible::Config for Runtime {882	type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;883}884impl pallet_nonfungible::Config for Runtime {885	type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;886}887888impl pallet_proxy_rmrk_core::Config for Runtime {889	type Event = Event;890}891892impl pallet_proxy_rmrk_equip::Config for Runtime {893	type Event = Event;894}895896impl pallet_unique::Config for Runtime {897	type Event = Event;898	type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;899	type CommonWeightInfo = CommonWeights<Self>;900}901902parameter_types! {903	pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied904}905906/// Used for the pallet inflation907impl pallet_inflation::Config for Runtime {908	type Currency = Balances;909	type TreasuryAccountId = TreasuryAccountId;910	type InflationBlockInterval = InflationBlockInterval;911	type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;912}913914// parameter_types! {915// 	pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *916// 		RuntimeBlockWeights::get().max_block;917// 	pub const MaxScheduledPerBlock: u32 = 50;918// }919920type EvmSponsorshipHandler = (921	UniqueEthSponsorshipHandler<Runtime>,922	pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,923);924type SponsorshipHandler = (925	UniqueSponsorshipHandler<Runtime>,926	//pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,927	pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,928);929930// impl pallet_unq_scheduler::Config for Runtime {931// 	type Event = Event;932// 	type Origin = Origin;933// 	type PalletsOrigin = OriginCaller;934// 	type Call = Call;935// 	type MaximumWeight = MaximumSchedulerWeight;936// 	type ScheduleOrigin = EnsureSigned<AccountId>;937// 	type MaxScheduledPerBlock = MaxScheduledPerBlock;938// 	type SponsorshipHandler = SponsorshipHandler;939// 	type WeightInfo = ();940// }941942impl pallet_evm_transaction_payment::Config for Runtime {943	type EvmSponsorshipHandler = EvmSponsorshipHandler;944	type Currency = Balances;945}946947impl pallet_charge_transaction::Config for Runtime {948	type SponsorshipHandler = SponsorshipHandler;949}950951// impl pallet_contract_helpers::Config for Runtime {952//	 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;953// }954955parameter_types! {956	// 0x842899ECF380553E8a4de75bF534cdf6fBF64049957	pub const HelpersContractAddress: H160 = H160([958		0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,959	]);960		961	// 0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f962	pub const EvmCollectionAddress: H160 = H160([963		0x6c, 0x4e, 0x9f, 0xe1, 0xae, 0x37, 0xa4, 0x1e, 0x93, 0xce, 0xe4, 0x29, 0xe8, 0xe1, 0x88, 0x1a, 0xbd, 0xcb, 0xb5, 0x4f,964	]);965}966967impl pallet_evm_contract_helpers::Config for Runtime {968	type ContractAddress = HelpersContractAddress;969	type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;970}971972impl pallet_evm_collection::Config for Runtime {973	type ContractAddress = EvmCollectionAddress;974}975976construct_runtime!(977	pub enum Runtime where978		Block = Block,979		NodeBlock = opaque::Block,980		UncheckedExtrinsic = UncheckedExtrinsic981	{982		ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,983		ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,984985		Aura: pallet_aura::{Pallet, Config<T>} = 22,986		AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,987988		Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,989		RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,990		Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,991		TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,992		Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,993		Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,994		System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,995		Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,996		// Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,997		// Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,998999		// XCM helpers.1000		XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,1001		PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,1002		CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,1003		DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,10041005		// Unique Pallets1006		Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,1007		Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,1008		// Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,1009		// free = 631010		Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,1011		// ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,1012		Common: pallet_common::{Pallet, Storage, Event<T>} = 66,1013		Fungible: pallet_fungible::{Pallet, Storage} = 67,1014		Refungible: pallet_refungible::{Pallet, Storage} = 68,1015		Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1016		Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1017		RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,1018		RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,10191020		// Frontier1021		EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1022		Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,10231024		EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1025		EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1026		EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1027		EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1028		EvmCollection: pallet_evm_collection::{Pallet} = 154,1029	}1030);10311032pub struct TransactionConverter;10331034impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1035	fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1036		UncheckedExtrinsic::new_unsigned(1037			pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1038		)1039	}1040}10411042impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1043	fn convert_transaction(1044		&self,1045		transaction: pallet_ethereum::Transaction,1046	) -> opaque::UncheckedExtrinsic {1047		let extrinsic = UncheckedExtrinsic::new_unsigned(1048			pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1049		);1050		let encoded = extrinsic.encode();1051		opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1052			.expect("Encoded extrinsic is always valid")1053	}1054}10551056/// The address format for describing accounts.1057pub type Address = sp_runtime::MultiAddress<AccountId, ()>;1058/// Block header type as expected by this runtime.1059pub type Header = generic::Header<BlockNumber, BlakeTwo256>;1060/// Block type as expected by this runtime.1061pub type Block = generic::Block<Header, UncheckedExtrinsic>;1062/// A Block signed with a Justification1063pub type SignedBlock = generic::SignedBlock<Block>;1064/// BlockId type as expected by this runtime.1065pub type BlockId = generic::BlockId<Block>;1066/// The SignedExtension to the basic transaction logic.1067pub type SignedExtra = (1068	frame_system::CheckSpecVersion<Runtime>,1069	// system::CheckTxVersion<Runtime>,1070	frame_system::CheckGenesis<Runtime>,1071	frame_system::CheckEra<Runtime>,1072	frame_system::CheckNonce<Runtime>,1073	frame_system::CheckWeight<Runtime>,1074	pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1075	//pallet_contract_helpers::ContractHelpersExtension<Runtime>,1076	pallet_ethereum::FakeTransactionFinalizer<Runtime>,1077);1078/// Unchecked extrinsic type as expected by this runtime.1079pub type UncheckedExtrinsic =1080	fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;1081/// Extrinsic type that has already been checked.1082pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;1083/// Executive: handles dispatch to the various modules.1084pub type Executive = frame_executive::Executive<1085	Runtime,1086	Block,1087	frame_system::ChainContext<Runtime>,1088	Runtime,1089	AllPalletsReversedWithSystemFirst,1090>;10911092impl_opaque_keys! {1093	pub struct SessionKeys {1094		pub aura: Aura,1095	}1096}10971098impl fp_self_contained::SelfContainedCall for Call {1099	type SignedInfo = H160;11001101	fn is_self_contained(&self) -> bool {1102		match self {1103			Call::Ethereum(call) => call.is_self_contained(),1104			_ => false,1105		}1106	}11071108	fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1109		match self {1110			Call::Ethereum(call) => call.check_self_contained(),1111			_ => None,1112		}1113	}11141115	fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1116		match self {1117			Call::Ethereum(call) => call.validate_self_contained(info),1118			_ => None,1119		}1120	}11211122	fn pre_dispatch_self_contained(1123		&self,1124		info: &Self::SignedInfo,1125	) -> Option<Result<(), TransactionValidityError>> {1126		match self {1127			Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1128			_ => None,1129		}1130	}11311132	fn apply_self_contained(1133		self,1134		info: Self::SignedInfo,1135	) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1136		match self {1137			call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1138				Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1139			)),1140			_ => None,1141		}1142	}1143}11441145macro_rules! dispatch_unique_runtime {1146	($collection:ident.$method:ident($($name:ident),*)) => {{1147		let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1148		let dispatch = collection.as_dyn();11491150		Ok::<_, DispatchError>(dispatch.$method($($name),*))1151	}};1152}11531154impl_common_runtime_apis!();11551156struct CheckInherents;11571158impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1159	fn check_inherents(1160		block: &Block,1161		relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1162	) -> sp_inherents::CheckInherentsResult {1163		let relay_chain_slot = relay_state_proof1164			.read_slot()1165			.expect("Could not read the relay chain slot from the proof");11661167		let inherent_data =1168			cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1169				relay_chain_slot,1170				sp_std::time::Duration::from_secs(6),1171			)1172			.create_inherent_data()1173			.expect("Could not create the timestamp inherent data");11741175		inherent_data.check_extrinsics(block)1176	}1177}11781179cumulus_pallet_parachain_system::register_validate_block!(1180	Runtime = Runtime,1181	BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1182	CheckInherents = CheckInherents,1183);
addedtests/src/eth/api/Collection.soldiffbeforeafterboth
--- /dev/null
+++ b/tests/src/eth/api/Collection.sol
@@ -0,0 +1,81 @@
+// SPDX-License-Identifier: OTHER
+// This code is automatically generated
+
+pragma solidity >=0.8.0 <0.9.0;
+
+// Common stubs holder
+interface Dummy {
+
+}
+
+interface ERC165 is Dummy {
+	function supportsInterface(bytes4 interfaceID) external view returns (bool);
+}
+
+// Selector: ee5467a8
+interface Collection is Dummy, ERC165 {
+	// Selector: contractOwner(address) 5152b14c
+	function contractOwner(address contractAddress)
+		external
+		view
+		returns (address);
+
+	// Selector: sponsoringEnabled(address) 6027dc61
+	function sponsoringEnabled(address contractAddress)
+		external
+		view
+		returns (bool);
+
+	// Deprecated
+	//
+	// Selector: toggleSponsoring(address,bool) fcac6d86
+	function toggleSponsoring(address contractAddress, bool enabled) external;
+
+	// Selector: setSponsoringMode(address,uint8) fde8a560
+	function setSponsoringMode(address contractAddress, uint8 mode) external;
+
+	// Selector: sponsoringMode(address) b70c7267
+	function sponsoringMode(address contractAddress)
+		external
+		view
+		returns (uint8);
+
+	// Selector: setSponsoringRateLimit(address,uint32) 77b6c908
+	function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)
+		external;
+
+	// Selector: getSponsoringRateLimit(address) 610cfabd
+	function getSponsoringRateLimit(address contractAddress)
+		external
+		view
+		returns (uint32);
+
+	// Selector: allowed(address,address) 5c658165
+	function allowed(address contractAddress, address user)
+		external
+		view
+		returns (bool);
+
+	// Selector: allowlistEnabled(address) c772ef6c
+	function allowlistEnabled(address contractAddress)
+		external
+		view
+		returns (bool);
+
+	// Selector: toggleAllowlist(address,bool) 36de20f5
+	function toggleAllowlist(address contractAddress, bool enabled) external;
+
+	// Selector: toggleAllowed(address,address,bool) 4706cc1c
+	function toggleAllowed(
+		address contractAddress,
+		address user,
+		bool allowed
+	) external;
+
+	// Selector: create721Collection(string,string,string) 951c0151
+	function create721Collection(
+		string memory name,
+		string memory description,
+		string memory tokenPrefix
+	) external view returns (address);
+}
modifiedtests/src/eth/api/ContractHelpers.soldiffbeforeafterboth
--- a/tests/src/eth/api/ContractHelpers.sol
+++ b/tests/src/eth/api/ContractHelpers.sol
@@ -12,7 +12,7 @@
 	function supportsInterface(bytes4 interfaceID) external view returns (bool);
 }
 
-// Selector: ee5467a8
+// Selector: 7b4866f9
 interface ContractHelpers is Dummy, ERC165 {
 	// Selector: contractOwner(address) 5152b14c
 	function contractOwner(address contractAddress)
@@ -71,11 +71,4 @@
 		address user,
 		bool allowed
 	) external;
-
-	// Selector: create721Collection(string,string,string) 951c0151
-	function create721Collection(
-		string memory name,
-		string memory description,
-		string memory tokenPrefix
-	) external view returns (address);
 }
addedtests/src/eth/collectionAbi.jsondiffbeforeafterboth
--- /dev/null
+++ b/tests/src/eth/collectionAbi.json
@@ -0,0 +1,172 @@
+[
+  {
+    "inputs": [
+      {
+        "internalType": "address",
+        "name": "contractAddress",
+        "type": "address"
+      },
+      { "internalType": "address", "name": "user", "type": "address" }
+    ],
+    "name": "allowed",
+    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "inputs": [
+      {
+        "internalType": "address",
+        "name": "contractAddress",
+        "type": "address"
+      }
+    ],
+    "name": "allowlistEnabled",
+    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "inputs": [
+      {
+        "internalType": "address",
+        "name": "contractAddress",
+        "type": "address"
+      }
+    ],
+    "name": "contractOwner",
+    "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "inputs": [
+      { "internalType": "string", "name": "name", "type": "string" },
+      { "internalType": "string", "name": "description", "type": "string" },
+      { "internalType": "string", "name": "tokenPrefix", "type": "string" }
+    ],
+    "name": "create721Collection",
+    "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "inputs": [
+      {
+        "internalType": "address",
+        "name": "contractAddress",
+        "type": "address"
+      }
+    ],
+    "name": "getSponsoringRateLimit",
+    "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }],
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "inputs": [
+      {
+        "internalType": "address",
+        "name": "contractAddress",
+        "type": "address"
+      },
+      { "internalType": "uint8", "name": "mode", "type": "uint8" }
+    ],
+    "name": "setSponsoringMode",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
+      {
+        "internalType": "address",
+        "name": "contractAddress",
+        "type": "address"
+      },
+      { "internalType": "uint32", "name": "rateLimit", "type": "uint32" }
+    ],
+    "name": "setSponsoringRateLimit",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
+      {
+        "internalType": "address",
+        "name": "contractAddress",
+        "type": "address"
+      }
+    ],
+    "name": "sponsoringEnabled",
+    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "inputs": [
+      {
+        "internalType": "address",
+        "name": "contractAddress",
+        "type": "address"
+      }
+    ],
+    "name": "sponsoringMode",
+    "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }],
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "inputs": [
+      { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }
+    ],
+    "name": "supportsInterface",
+    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "inputs": [
+      {
+        "internalType": "address",
+        "name": "contractAddress",
+        "type": "address"
+      },
+      { "internalType": "address", "name": "user", "type": "address" },
+      { "internalType": "bool", "name": "allowed", "type": "bool" }
+    ],
+    "name": "toggleAllowed",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
+      {
+        "internalType": "address",
+        "name": "contractAddress",
+        "type": "address"
+      },
+      { "internalType": "bool", "name": "enabled", "type": "bool" }
+    ],
+    "name": "toggleAllowlist",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
+      {
+        "internalType": "address",
+        "name": "contractAddress",
+        "type": "address"
+      },
+      { "internalType": "bool", "name": "enabled", "type": "bool" }
+    ],
+    "name": "toggleSponsoring",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  }
+]
modifiedtests/src/eth/createCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createCollection.test.ts
+++ b/tests/src/eth/createCollection.test.ts
@@ -16,12 +16,12 @@
 
 import {expect} from 'chai';
 import {getCreatedCollectionCount, getDetailedCollectionInfo} from '../util/helpers';
-import {collectionIdFromAddress, contractHelpers, createEthAccountWithBalance, itWeb3} from './util/helpers';
+import {collectionHelper, collectionIdFromAddress, contractHelpers, createEthAccountWithBalance, itWeb3} from './util/helpers';
 
 describe('Create collection from EVM', () => {
   itWeb3('Create collection', async ({api, web3}) => {
     const owner = await createEthAccountWithBalance(api, web3);
-    const helpers = contractHelpers(web3, owner);
+    const helpers = collectionHelper(web3, owner);
     const collectionName = 'CollectionEVM';
     const description = 'Some description';
     const tokenPrefix = 'token prefix';
modifiedtests/src/eth/util/contractHelpersAbi.jsondiffbeforeafterboth
--- a/tests/src/eth/util/contractHelpersAbi.json
+++ b/tests/src/eth/util/contractHelpersAbi.json
@@ -41,17 +41,6 @@
   },
   {
     "inputs": [
-      { "internalType": "string", "name": "name", "type": "string" },
-      { "internalType": "string", "name": "description", "type": "string" },
-      { "internalType": "string", "name": "tokenPrefix", "type": "string" }
-    ],
-    "name": "create721Collection",
-    "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
-    "stateMutability": "view",
-    "type": "function"
-  },
-  {
-    "inputs": [
       {
         "internalType": "address",
         "name": "contractAddress",
modifiedtests/src/eth/util/helpers.tsdiffbeforeafterboth
--- a/tests/src/eth/util/helpers.ts
+++ b/tests/src/eth/util/helpers.ts
@@ -28,6 +28,7 @@
 import config from '../../config';
 import privateKey from '../../substrate/privateKey';
 import contractHelpersAbi from './contractHelpersAbi.json';
+import collectionAbi from '../collectionAbi.json';
 import getBalance from '../../substrate/get-balance';
 import waitNewBlocks from '../../substrate/wait-new-blocks';
 
@@ -273,6 +274,16 @@
   return new web3.eth.Contract(contractHelpersAbi as any, '0x842899ECF380553E8a4de75bF534cdf6fBF64049', {from: caller, ...GAS_ARGS});
 }
 
+/** 
+ * pallet evm_collection
+ * @param web3 
+ * @param caller - eth address
+ * @returns 
+ */
+export function collectionHelper(web3: Web3, caller: string) {
+  return new web3.eth.Contract(collectionAbi as any, '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f', {from: caller, ...GAS_ARGS});
+}
+
 /**
  * Execute ethereum method call using substrate account
  * @param to target contract