difftreelog
CORE-302 Add EvmCollection Pallet
in: master
24 files changed
Cargo.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",
Makefilediffbeforeafterboth--- 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:
pallets/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",
+]
pallets/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);
pallets/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> {}
+}
pallets/evm-collection/src/stubs/Collection.rawdiffbeforeafterbothbinary blob — no preview
pallets/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;
+ }
+}
pallets/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>);
pallets/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::*;
pallets/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;
+ }
+}
pallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/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;
}
}
runtime/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" }
runtime/opal/src/lib.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! 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 up_data_structs::mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping};70use up_data_structs::*;71// use pallet_contracts::weights::WeightInfo;72// #[cfg(any(feature = "std", test))]73use frame_system::{74 self as frame_system, EnsureRoot, EnsureSigned,75 limits::{BlockWeights, BlockLength},76};77use sp_arithmetic::{78 traits::{BaseArithmetic, Unsigned},79};80use smallvec::smallvec;81use codec::{Encode, Decode};82use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping};83use fp_rpc::TransactionStatus;84use sp_runtime::{85 traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},86 transaction_validity::TransactionValidityError,87 SaturatedConversion,88};8990// pub use pallet_timestamp::Call as TimestampCall;91pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;9293// Polkadot imports94use pallet_xcm::XcmPassthrough;95use polkadot_parachain::primitives::Sibling;96use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};97use xcm_builder::{98 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,99 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,100 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,101 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,102 ParentIsPreset,103};104use xcm_executor::{Config, XcmExecutor, Assets};105use sp_std::{marker::PhantomData};106107use xcm::latest::{108 // Xcm,109 AssetId::{Concrete},110 Fungibility::Fungible as XcmFungible,111 MultiAsset,112 Error as XcmError,113};114use xcm_executor::traits::{MatchesFungible, WeightTrader};115//use xcm_executor::traits::MatchesFungible;116use sp_runtime::traits::CheckedConversion;117118use unique_runtime_common::{119 impl_common_runtime_apis,120 types::*,121 constants::*,122 dispatch::{CollectionDispatchT, CollectionDispatch},123 sponsoring::UniqueSponsorshipHandler,124 eth_sponsoring::UniqueEthSponsorshipHandler,125 weights::CommonWeights,126};127128pub const RUNTIME_NAME: &str = "opal";129pub const TOKEN_SYMBOL: &str = "OPL";130131type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;132133impl RuntimeInstance for Runtime {134 type CrossAccountId = self::CrossAccountId;135 type TransactionConverter = self::TransactionConverter;136137 fn get_transaction_converter() -> TransactionConverter {138 TransactionConverter139 }140}141142/// The type for looking up accounts. We don't expect more than 4 billion of them, but you143/// never know...144pub type AccountIndex = u32;145146/// Balance of an account.147pub type Balance = u128;148149/// Index of a transaction in the chain.150pub type Index = u32;151152/// A hash of some data used by the chain.153pub type Hash = sp_core::H256;154155/// Digest item type.156pub type DigestItem = generic::DigestItem;157158/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know159/// the specifics of the runtime. They can then be made to be agnostic over specific formats160/// of data like extrinsics, allowing for them to continue syncing the network through upgrades161/// to even the core data structures.162pub mod opaque {163 use sp_std::prelude::*;164 use sp_runtime::impl_opaque_keys;165 use super::Aura;166167 pub use unique_runtime_common::types::*;168169 impl_opaque_keys! {170 pub struct SessionKeys {171 pub aura: Aura,172 }173 }174}175176/// This runtime version.177pub const VERSION: RuntimeVersion = RuntimeVersion {178 spec_name: create_runtime_str!(RUNTIME_NAME),179 impl_name: create_runtime_str!(RUNTIME_NAME),180 authoring_version: 1,181 spec_version: 920000,182 impl_version: 0,183 apis: RUNTIME_API_VERSIONS,184 transaction_version: 1,185 state_version: 0,186};187188#[derive(codec::Encode, codec::Decode)]189pub enum XCMPMessage<XAccountId, XBalance> {190 /// Transfer tokens to the given account from the Parachain account.191 TransferToken(XAccountId, XBalance),192}193194/// The version information used to identify this runtime when compiled natively.195#[cfg(feature = "std")]196pub fn native_version() -> NativeVersion {197 NativeVersion {198 runtime_version: VERSION,199 can_author_with: Default::default(),200 }201}202203type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;204205pub struct DealWithFees;206impl OnUnbalanced<NegativeImbalance> for DealWithFees {207 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {208 if let Some(fees) = fees_then_tips.next() {209 // for fees, 100% to treasury210 let mut split = fees.ration(100, 0);211 if let Some(tips) = fees_then_tips.next() {212 // for tips, if any, 100% to treasury213 tips.ration_merge_into(100, 0, &mut split);214 }215 Treasury::on_unbalanced(split.0);216 // Author::on_unbalanced(split.1);217 }218 }219}220221parameter_types! {222 pub const BlockHashCount: BlockNumber = 2400;223 pub RuntimeBlockLength: BlockLength =224 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);225 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);226 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;227 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()228 .base_block(BlockExecutionWeight::get())229 .for_class(DispatchClass::all(), |weights| {230 weights.base_extrinsic = ExtrinsicBaseWeight::get();231 })232 .for_class(DispatchClass::Normal, |weights| {233 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);234 })235 .for_class(DispatchClass::Operational, |weights| {236 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);237 // Operational transactions have some extra reserved space, so that they238 // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.239 weights.reserved = Some(240 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT241 );242 })243 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)244 .build_or_panic();245 pub const Version: RuntimeVersion = VERSION;246 pub const SS58Prefix: u8 = 42;247}248249parameter_types! {250 pub const ChainId: u64 = 8882;251}252253pub struct FixedFee;254impl FeeCalculator for FixedFee {255 fn min_gas_price() -> U256 {256 MIN_GAS_PRICE.into()257 }258}259260// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case261// (contract, which only writes a lot of data),262// approximating on top of our real store write weight263parameter_types! {264 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;265 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;266 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();267}268269/// Limiting EVM execution to 50% of block for substrate users and management tasks270/// EVM transaction consumes more weight than substrate's, so we can't rely on them being271/// scheduled fairly272const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);273parameter_types! {274 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());275}276277pub enum FixedGasWeightMapping {}278impl GasWeightMapping for FixedGasWeightMapping {279 fn gas_to_weight(gas: u64) -> Weight {280 gas.saturating_mul(WeightPerGas::get())281 }282 fn weight_to_gas(weight: Weight) -> u64 {283 weight / WeightPerGas::get()284 }285}286287impl pallet_evm::account::Config for Runtime {288 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;289 type EvmAddressMapping = pallet_evm::HashedAddressMapping<Self::Hashing>;290 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;291}292293impl pallet_evm::Config for Runtime {294 type BlockGasLimit = BlockGasLimit;295 type FeeCalculator = FixedFee;296 type GasWeightMapping = FixedGasWeightMapping;297 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;298 type CallOrigin = EnsureAddressTruncated<Self>;299 type WithdrawOrigin = EnsureAddressTruncated<Self>;300 type AddressMapping = HashedAddressMapping<Self::Hashing>;301 type PrecompilesType = ();302 type PrecompilesValue = ();303 type Currency = Balances;304 type Event = Event;305 type OnMethodCall = (306 pallet_evm_migration::OnMethodCall<Self>,307 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,308 CollectionDispatchT<Self>,309 );310 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;311 type ChainId = ChainId;312 type Runner = pallet_evm::runner::stack::Runner<Self>;313 type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;314 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;315 type FindAuthor = EthereumFindAuthor<Aura>;316}317318impl pallet_evm_migration::Config for Runtime {319 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;320}321322pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);323impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {324 fn find_author<'a, I>(digests: I) -> Option<H160>325 where326 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,327 {328 if let Some(author_index) = F::find_author(digests) {329 let authority_id = Aura::authorities()[author_index as usize].clone();330 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));331 }332 None333 }334}335336impl pallet_ethereum::Config for Runtime {337 type Event = Event;338 type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;339}340341impl pallet_randomness_collective_flip::Config for Runtime {}342343impl frame_system::Config for Runtime {344 /// The data to be stored in an account.345 type AccountData = pallet_balances::AccountData<Balance>;346 /// The identifier used to distinguish between accounts.347 type AccountId = AccountId;348 /// The basic call filter to use in dispatchable.349 type BaseCallFilter = Everything;350 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).351 type BlockHashCount = BlockHashCount;352 /// The maximum length of a block (in bytes).353 type BlockLength = RuntimeBlockLength;354 /// The index type for blocks.355 type BlockNumber = BlockNumber;356 /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.357 type BlockWeights = RuntimeBlockWeights;358 /// The aggregated dispatch type that is available for extrinsics.359 type Call = Call;360 /// The weight of database operations that the runtime can invoke.361 type DbWeight = RocksDbWeight;362 /// The ubiquitous event type.363 type Event = Event;364 /// The type for hashing blocks and tries.365 type Hash = Hash;366 /// The hashing algorithm used.367 type Hashing = BlakeTwo256;368 /// The header type.369 type Header = generic::Header<BlockNumber, BlakeTwo256>;370 /// The index type for storing how many extrinsics an account has signed.371 type Index = Index;372 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.373 type Lookup = AccountIdLookup<AccountId, ()>;374 /// What to do if an account is fully reaped from the system.375 type OnKilledAccount = ();376 /// What to do if a new account is created.377 type OnNewAccount = ();378 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;379 /// The ubiquitous origin type.380 type Origin = Origin;381 /// This type is being generated by `construct_runtime!`.382 type PalletInfo = PalletInfo;383 /// This is used as an identifier of the chain. 42 is the generic substrate prefix.384 type SS58Prefix = SS58Prefix;385 /// Weight information for the extrinsics of this pallet.386 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;387 /// Version of the runtime.388 type Version = Version;389 type MaxConsumers = ConstU32<16>;390}391392parameter_types! {393 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;394}395396impl pallet_timestamp::Config for Runtime {397 /// A timestamp: milliseconds since the unix epoch.398 type Moment = u64;399 type OnTimestampSet = ();400 type MinimumPeriod = MinimumPeriod;401 type WeightInfo = ();402}403404parameter_types! {405 // pub const ExistentialDeposit: u128 = 500;406 pub const ExistentialDeposit: u128 = 0;407 pub const MaxLocks: u32 = 50;408}409410impl pallet_balances::Config for Runtime {411 type MaxLocks = MaxLocks;412 type MaxReserves = ();413 type ReserveIdentifier = [u8; 8];414 /// The type for recording an account's balance.415 type Balance = Balance;416 /// The ubiquitous event type.417 type Event = Event;418 type DustRemoval = Treasury;419 type ExistentialDeposit = ExistentialDeposit;420 type AccountStore = System;421 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;422}423424pub const fn deposit(items: u32, bytes: u32) -> Balance {425 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE426}427428/*429parameter_types! {430 pub TombstoneDeposit: Balance = deposit(431 1,432 sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,433 );434 pub DepositPerContract: Balance = TombstoneDeposit::get();435 pub const DepositPerStorageByte: Balance = deposit(0, 1);436 pub const DepositPerStorageItem: Balance = deposit(1, 0);437 pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);438 pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;439 pub const SignedClaimHandicap: u32 = 2;440 pub const MaxDepth: u32 = 32;441 pub const MaxValueSize: u32 = 16 * 1024;442 pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb443 // The lazy deletion runs inside on_initialize.444 pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *445 RuntimeBlockWeights::get().max_block;446 // The weight needed for decoding the queue should be less or equal than a fifth447 // of the overall weight dedicated to the lazy deletion.448 pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (449 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -450 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)451 )) / 5) as u32;452 pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();453}454455impl pallet_contracts::Config for Runtime {456 type Time = Timestamp;457 type Randomness = RandomnessCollectiveFlip;458 type Currency = Balances;459 type Event = Event;460 type RentPayment = ();461 type SignedClaimHandicap = SignedClaimHandicap;462 type TombstoneDeposit = TombstoneDeposit;463 type DepositPerContract = DepositPerContract;464 type DepositPerStorageByte = DepositPerStorageByte;465 type DepositPerStorageItem = DepositPerStorageItem;466 type RentFraction = RentFraction;467 type SurchargeReward = SurchargeReward;468 type WeightPrice = pallet_transaction_payment::Pallet<Self>;469 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;470 type ChainExtension = NFTExtension;471 type DeletionQueueDepth = DeletionQueueDepth;472 type DeletionWeightLimit = DeletionWeightLimit;473 type Schedule = Schedule;474 type CallStack = [pallet_contracts::Frame<Self>; 31];475}476*/477478parameter_types! {479 /// This value increases the priority of `Operational` transactions by adding480 /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.481 pub const OperationalFeeMultiplier: u8 = 5;482}483484/// Linear implementor of `WeightToFeePolynomial`485pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);486487impl<T> WeightToFeePolynomial for LinearFee<T>488where489 T: BaseArithmetic + From<u32> + Copy + Unsigned,490{491 type Balance = T;492493 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {494 smallvec!(WeightToFeeCoefficient {495 // Targeting 0.1 Unique per NFT transfer496 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),497 coeff_frac: Perbill::zero(),498 negative: false,499 degree: 1,500 })501 }502}503504impl pallet_transaction_payment::Config for Runtime {505 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;506 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;507 type OperationalFeeMultiplier = OperationalFeeMultiplier;508 type WeightToFee = LinearFee<Balance>;509 type FeeMultiplierUpdate = ();510}511512parameter_types! {513 pub const ProposalBond: Permill = Permill::from_percent(5);514 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;515 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;516 pub const SpendPeriod: BlockNumber = 5 * MINUTES;517 pub const Burn: Permill = Permill::from_percent(0);518 pub const TipCountdown: BlockNumber = 1 * DAYS;519 pub const TipFindersFee: Percent = Percent::from_percent(20);520 pub const TipReportDepositBase: Balance = 1 * UNIQUE;521 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;522 pub const BountyDepositBase: Balance = 1 * UNIQUE;523 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;524 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");525 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;526 pub const MaximumReasonLength: u32 = 16384;527 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);528 pub const BountyValueMinimum: Balance = 5 * UNIQUE;529 pub const MaxApprovals: u32 = 100;530}531532impl pallet_treasury::Config for Runtime {533 type PalletId = TreasuryModuleId;534 type Currency = Balances;535 type ApproveOrigin = EnsureRoot<AccountId>;536 type RejectOrigin = EnsureRoot<AccountId>;537 type Event = Event;538 type OnSlash = ();539 type ProposalBond = ProposalBond;540 type ProposalBondMinimum = ProposalBondMinimum;541 type ProposalBondMaximum = ProposalBondMaximum;542 type SpendPeriod = SpendPeriod;543 type Burn = Burn;544 type BurnDestination = ();545 type SpendFunds = ();546 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;547 type MaxApprovals = MaxApprovals;548}549550impl pallet_sudo::Config for Runtime {551 type Event = Event;552 type Call = Call;553}554555pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);556557impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider558 for RelayChainBlockNumberProvider<T>559{560 type BlockNumber = BlockNumber;561562 fn current_block_number() -> Self::BlockNumber {563 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()564 .map(|d| d.relay_parent_number)565 .unwrap_or_default()566 }567}568569parameter_types! {570 pub const MinVestedTransfer: Balance = 10 * UNIQUE;571 pub const MaxVestingSchedules: u32 = 28;572}573574impl orml_vesting::Config for Runtime {575 type Event = Event;576 type Currency = pallet_balances::Pallet<Runtime>;577 type MinVestedTransfer = MinVestedTransfer;578 type VestedTransferOrigin = EnsureSigned<AccountId>;579 type WeightInfo = ();580 type MaxVestingSchedules = MaxVestingSchedules;581 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;582}583584parameter_types! {585 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;586 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;587}588589impl cumulus_pallet_parachain_system::Config for Runtime {590 type Event = Event;591 type SelfParaId = parachain_info::Pallet<Self>;592 type OnSystemEvent = ();593 // type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<594 // MaxDownwardMessageWeight,595 // XcmExecutor<XcmConfig>,596 // Call,597 // >;598 type OutboundXcmpMessageSource = XcmpQueue;599 type DmpMessageHandler = DmpQueue;600 type ReservedDmpWeight = ReservedDmpWeight;601 type ReservedXcmpWeight = ReservedXcmpWeight;602 type XcmpMessageHandler = XcmpQueue;603}604605impl parachain_info::Config for Runtime {}606607impl cumulus_pallet_aura_ext::Config for Runtime {}608609parameter_types! {610 pub const RelayLocation: MultiLocation = MultiLocation::parent();611 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;612 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();613 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();614}615616/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used617/// when determining ownership of accounts for asset transacting and when attempting to use XCM618/// `Transact` in order to determine the dispatch Origin.619pub type LocationToAccountId = (620 // The parent (Relay-chain) origin converts to the default `AccountId`.621 ParentIsPreset<AccountId>,622 // Sibling parachain origins convert to AccountId via the `ParaId::into`.623 SiblingParachainConvertsVia<Sibling, AccountId>,624 // Straight up local `AccountId32` origins just alias directly to `AccountId`.625 AccountId32Aliases<RelayNetwork, AccountId>,626);627628pub struct OnlySelfCurrency;629impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {630 fn matches_fungible(a: &MultiAsset) -> Option<B> {631 match (&a.id, &a.fun) {632 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),633 _ => None,634 }635 }636}637638/// Means for transacting assets on this chain.639pub type LocalAssetTransactor = CurrencyAdapter<640 // Use this currency:641 Balances,642 // Use this currency when it is a fungible asset matching the given location or name:643 OnlySelfCurrency,644 // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:645 LocationToAccountId,646 // Our chain's account ID type (we can't get away without mentioning it explicitly):647 AccountId,648 // We don't track any teleports.649 (),650>;651652/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,653/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can654/// biases the kind of local `Origin` it will become.655pub type XcmOriginToTransactDispatchOrigin = (656 // Sovereign account converter; this attempts to derive an `AccountId` from the origin location657 // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for658 // foreign chains who want to have a local sovereign account on this chain which they control.659 SovereignSignedViaLocation<LocationToAccountId, Origin>,660 // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when661 // recognised.662 RelayChainAsNative<RelayOrigin, Origin>,663 // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when664 // recognised.665 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,666 // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a667 // transaction from the Root origin.668 ParentAsSuperuser<Origin>,669 // Native signed account converter; this just converts an `AccountId32` origin into a normal670 // `Origin::Signed` origin of the same 32-byte value.671 SignedAccountId32AsNative<RelayNetwork, Origin>,672 // Xcm origins can be represented natively under the Xcm pallet's Xcm origin.673 XcmPassthrough<Origin>,674);675676parameter_types! {677 // One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.678 pub UnitWeightCost: Weight = 1_000_000;679 // 1200 UNIQUEs buy 1 second of weight.680 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);681 pub const MaxInstructions: u32 = 100;682 pub const MaxAuthorities: u32 = 100_000;683}684685match_types! {686 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {687 MultiLocation { parents: 1, interior: Here } |688 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }689 };690}691692pub type Barrier = (693 TakeWeightCredit,694 AllowTopLevelPaidExecutionFrom<Everything>,695 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,696 // ^^^ Parent & its unit plurality gets free execution697);698699pub struct UsingOnlySelfCurrencyComponents<700 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,701 AssetId: Get<MultiLocation>,702 AccountId,703 Currency: CurrencyT<AccountId>,704 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,705>(706 Weight,707 Currency::Balance,708 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,709);710impl<711 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,712 AssetId: Get<MultiLocation>,713 AccountId,714 Currency: CurrencyT<AccountId>,715 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,716 > WeightTrader717 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>718{719 fn new() -> Self {720 Self(0, Zero::zero(), PhantomData)721 }722723 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {724 let amount = WeightToFee::calc(&weight);725 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;726727 // location to this parachain through relay chain728 let option1: xcm::v1::AssetId = Concrete(MultiLocation {729 parents: 1,730 interior: X1(Parachain(ParachainInfo::parachain_id().into())),731 });732 // direct location733 let option2: xcm::v1::AssetId = Concrete(MultiLocation {734 parents: 0,735 interior: Here,736 });737738 let required = if payment.fungible.contains_key(&option1) {739 (option1, u128_amount).into()740 } else if payment.fungible.contains_key(&option2) {741 (option2, u128_amount).into()742 } else {743 (Concrete(MultiLocation::default()), u128_amount).into()744 };745746 let unused = payment747 .checked_sub(required)748 .map_err(|_| XcmError::TooExpensive)?;749 self.0 = self.0.saturating_add(weight);750 self.1 = self.1.saturating_add(amount);751 Ok(unused)752 }753754 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {755 let weight = weight.min(self.0);756 let amount = WeightToFee::calc(&weight);757 self.0 -= weight;758 self.1 = self.1.saturating_sub(amount);759 let amount: u128 = amount.saturated_into();760 if amount > 0 {761 Some((AssetId::get(), amount).into())762 } else {763 None764 }765 }766}767impl<768 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,769 AssetId: Get<MultiLocation>,770 AccountId,771 Currency: CurrencyT<AccountId>,772 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,773 > Drop774 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>775{776 fn drop(&mut self) {777 OnUnbalanced::on_unbalanced(Currency::issue(self.1));778 }779}780781pub struct XcmConfig;782impl Config for XcmConfig {783 type Call = Call;784 type XcmSender = XcmRouter;785 // How to withdraw and deposit an asset.786 type AssetTransactor = LocalAssetTransactor;787 type OriginConverter = XcmOriginToTransactDispatchOrigin;788 type IsReserve = NativeAsset;789 type IsTeleporter = (); // Teleportation is disabled790 type LocationInverter = LocationInverter<Ancestry>;791 type Barrier = Barrier;792 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;793 type Trader = UsingOnlySelfCurrencyComponents<794 IdentityFee<Balance>,795 RelayLocation,796 AccountId,797 Balances,798 (),799 >;800 type ResponseHandler = (); // Don't handle responses for now.801 type SubscriptionService = PolkadotXcm;802803 type AssetTrap = PolkadotXcm;804 type AssetClaims = PolkadotXcm;805}806807// parameter_types! {808// pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;809// }810811/// No local origins on this chain are allowed to dispatch XCM sends/executions.812pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);813814/// The means for routing XCM messages which are not for local execution into the right message815/// queues.816pub type XcmRouter = (817 // Two routers - use UMP to communicate with the relay chain:818 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,819 // ..and XCMP to communicate with the sibling chains.820 XcmpQueue,821);822823impl pallet_evm_coder_substrate::Config for Runtime {824 type GasWeightMapping = FixedGasWeightMapping;825}826827impl pallet_xcm::Config for Runtime {828 type Event = Event;829 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;830 type XcmRouter = XcmRouter;831 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;832 type XcmExecuteFilter = Everything;833 type XcmExecutor = XcmExecutor<XcmConfig>;834 type XcmTeleportFilter = Everything;835 type XcmReserveTransferFilter = Everything;836 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;837 type LocationInverter = LocationInverter<Ancestry>;838 type Origin = Origin;839 type Call = Call;840 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;841 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;842}843844impl cumulus_pallet_xcm::Config for Runtime {845 type Event = Event;846 type XcmExecutor = XcmExecutor<XcmConfig>;847}848849impl cumulus_pallet_xcmp_queue::Config for Runtime {850 type WeightInfo = ();851 type Event = Event;852 type XcmExecutor = XcmExecutor<XcmConfig>;853 type ChannelInfo = ParachainSystem;854 type VersionWrapper = ();855 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;856 type ControllerOrigin = EnsureRoot<AccountId>;857 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;858}859860impl cumulus_pallet_dmp_queue::Config for Runtime {861 type Event = Event;862 type XcmExecutor = XcmExecutor<XcmConfig>;863 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;864}865866impl pallet_aura::Config for Runtime {867 type AuthorityId = AuraId;868 type DisabledValidators = ();869 type MaxAuthorities = MaxAuthorities;870}871872parameter_types! {873 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();874 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;875}876877impl pallet_common::Config for Runtime {878 type WeightInfo = pallet_common::weights::SubstrateWeight<Self>;879 type Event = Event;880 type Currency = Balances;881 type CollectionCreationPrice = CollectionCreationPrice;882 type TreasuryAccountId = TreasuryAccountId;883 type CollectionDispatch = CollectionDispatchT<Self>;884885 type EvmTokenAddressMapping = EvmTokenAddressMapping;886 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;887}888889impl pallet_structure::Config for Runtime {890 type Event = Event;891 type Call = Call;892 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;893}894895impl pallet_fungible::Config for Runtime {896 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;897}898impl pallet_refungible::Config for Runtime {899 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;900}901impl pallet_nonfungible::Config for Runtime {902 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;903}904905impl pallet_proxy_rmrk_core::Config for Runtime {906 type Event = Event;907}908909impl pallet_proxy_rmrk_equip::Config for Runtime {910 type Event = Event;911}912913impl pallet_unique::Config for Runtime {914 type Event = Event;915 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;916 type CommonWeightInfo = CommonWeights<Self>;917}918919parameter_types! {920 pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied921}922923/// Used for the pallet inflation924impl pallet_inflation::Config for Runtime {925 type Currency = Balances;926 type TreasuryAccountId = TreasuryAccountId;927 type InflationBlockInterval = InflationBlockInterval;928 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;929}930931// parameter_types! {932// pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *933// RuntimeBlockWeights::get().max_block;934// pub const MaxScheduledPerBlock: u32 = 50;935// }936937type EvmSponsorshipHandler = (938 UniqueEthSponsorshipHandler<Runtime>,939 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,940);941type SponsorshipHandler = (942 UniqueSponsorshipHandler<Runtime>,943 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,944 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,945);946947// impl pallet_unq_scheduler::Config for Runtime {948// type Event = Event;949// type Origin = Origin;950// type PalletsOrigin = OriginCaller;951// type Call = Call;952// type MaximumWeight = MaximumSchedulerWeight;953// type ScheduleOrigin = EnsureSigned<AccountId>;954// type MaxScheduledPerBlock = MaxScheduledPerBlock;955// type SponsorshipHandler = SponsorshipHandler;956// type WeightInfo = ();957// }958959impl pallet_evm_transaction_payment::Config for Runtime {960 type EvmSponsorshipHandler = EvmSponsorshipHandler;961 type Currency = Balances;962}963964impl pallet_charge_transaction::Config for Runtime {965 type SponsorshipHandler = SponsorshipHandler;966}967968// impl pallet_contract_helpers::Config for Runtime {969// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;970// }971972parameter_types! {973 // 0x842899ECF380553E8a4de75bF534cdf6fBF64049974 pub const HelpersContractAddress: H160 = H160([975 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,976 ]);977}978979impl pallet_evm_contract_helpers::Config for Runtime {980 type ContractAddress = HelpersContractAddress;981 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;982}983984construct_runtime!(985 pub enum Runtime where986 Block = Block,987 NodeBlock = opaque::Block,988 UncheckedExtrinsic = UncheckedExtrinsic989 {990 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,991 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,992993 Aura: pallet_aura::{Pallet, Config<T>} = 22,994 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,995996 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,997 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,998 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,999 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,1000 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,1001 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,1002 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,1003 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,1004 // Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,1005 // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,10061007 // XCM helpers.1008 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,1009 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,1010 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,1011 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,10121013 // Unique Pallets1014 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,1015 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,1016 // Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,1017 // free = 631018 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,1019 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,1020 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,1021 Fungible: pallet_fungible::{Pallet, Storage} = 67,1022 Refungible: pallet_refungible::{Pallet, Storage} = 68,1023 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1024 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1025 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,1026 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,10271028 // Frontier1029 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1030 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,10311032 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1033 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1034 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1035 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1036 }1037);10381039pub struct TransactionConverter;10401041impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1042 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1043 UncheckedExtrinsic::new_unsigned(1044 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1045 )1046 }1047}10481049impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1050 fn convert_transaction(1051 &self,1052 transaction: pallet_ethereum::Transaction,1053 ) -> opaque::UncheckedExtrinsic {1054 let extrinsic = UncheckedExtrinsic::new_unsigned(1055 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1056 );1057 let encoded = extrinsic.encode();1058 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1059 .expect("Encoded extrinsic is always valid")1060 }1061}10621063/// The address format for describing accounts.1064pub type Address = sp_runtime::MultiAddress<AccountId, ()>;1065/// Block header type as expected by this runtime.1066pub type Header = generic::Header<BlockNumber, BlakeTwo256>;1067/// Block type as expected by this runtime.1068pub type Block = generic::Block<Header, UncheckedExtrinsic>;1069/// A Block signed with a Justification1070pub type SignedBlock = generic::SignedBlock<Block>;1071/// BlockId type as expected by this runtime.1072pub type BlockId = generic::BlockId<Block>;1073/// The SignedExtension to the basic transaction logic.1074pub type SignedExtra = (1075 frame_system::CheckSpecVersion<Runtime>,1076 // system::CheckTxVersion<Runtime>,1077 frame_system::CheckGenesis<Runtime>,1078 frame_system::CheckEra<Runtime>,1079 frame_system::CheckNonce<Runtime>,1080 frame_system::CheckWeight<Runtime>,1081 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1082 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,1083 pallet_ethereum::FakeTransactionFinalizer<Runtime>,1084);1085/// Unchecked extrinsic type as expected by this runtime.1086pub type UncheckedExtrinsic =1087 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;1088/// Extrinsic type that has already been checked.1089pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;1090/// Executive: handles dispatch to the various modules.1091pub type Executive = frame_executive::Executive<1092 Runtime,1093 Block,1094 frame_system::ChainContext<Runtime>,1095 Runtime,1096 AllPalletsReversedWithSystemFirst,1097>;10981099impl_opaque_keys! {1100 pub struct SessionKeys {1101 pub aura: Aura,1102 }1103}11041105impl fp_self_contained::SelfContainedCall for Call {1106 type SignedInfo = H160;11071108 fn is_self_contained(&self) -> bool {1109 match self {1110 Call::Ethereum(call) => call.is_self_contained(),1111 _ => false,1112 }1113 }11141115 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1116 match self {1117 Call::Ethereum(call) => call.check_self_contained(),1118 _ => None,1119 }1120 }11211122 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1123 match self {1124 Call::Ethereum(call) => call.validate_self_contained(info),1125 _ => None,1126 }1127 }11281129 fn pre_dispatch_self_contained(1130 &self,1131 info: &Self::SignedInfo,1132 ) -> Option<Result<(), TransactionValidityError>> {1133 match self {1134 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1135 _ => None,1136 }1137 }11381139 fn apply_self_contained(1140 self,1141 info: Self::SignedInfo,1142 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1143 match self {1144 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1145 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1146 )),1147 _ => None,1148 }1149 }1150}11511152macro_rules! dispatch_unique_runtime {1153 ($collection:ident.$method:ident($($name:ident),*)) => {{1154 let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1155 let dispatch = collection.as_dyn();11561157 Ok::<_, DispatchError>(dispatch.$method($($name),*))1158 }};1159}11601161impl_common_runtime_apis!();11621163struct CheckInherents;11641165impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1166 fn check_inherents(1167 block: &Block,1168 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1169 ) -> sp_inherents::CheckInherentsResult {1170 let relay_chain_slot = relay_state_proof1171 .read_slot()1172 .expect("Could not read the relay chain slot from the proof");11731174 let inherent_data =1175 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1176 relay_chain_slot,1177 sp_std::time::Duration::from_secs(6),1178 )1179 .create_inherent_data()1180 .expect("Could not create the timestamp inherent data");11811182 inherent_data.check_extrinsics(block)1183 }1184}11851186cumulus_pallet_parachain_system::register_validate_block!(1187 Runtime = Runtime,1188 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1189 CheckInherents = CheckInherents,1190);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 up_data_structs::mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping};70use up_data_structs::*;71// use pallet_contracts::weights::WeightInfo;72// #[cfg(any(feature = "std", test))]73use frame_system::{74 self as frame_system, EnsureRoot, EnsureSigned,75 limits::{BlockWeights, BlockLength},76};77use sp_arithmetic::{78 traits::{BaseArithmetic, Unsigned},79};80use smallvec::smallvec;81use codec::{Encode, Decode};82use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping};83use fp_rpc::TransactionStatus;84use sp_runtime::{85 traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},86 transaction_validity::TransactionValidityError,87 SaturatedConversion,88};8990// pub use pallet_timestamp::Call as TimestampCall;91pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;9293// Polkadot imports94use pallet_xcm::XcmPassthrough;95use polkadot_parachain::primitives::Sibling;96use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};97use xcm_builder::{98 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,99 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,100 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,101 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,102 ParentIsPreset,103};104use xcm_executor::{Config, XcmExecutor, Assets};105use sp_std::{marker::PhantomData};106107use xcm::latest::{108 // Xcm,109 AssetId::{Concrete},110 Fungibility::Fungible as XcmFungible,111 MultiAsset,112 Error as XcmError,113};114use xcm_executor::traits::{MatchesFungible, WeightTrader};115//use xcm_executor::traits::MatchesFungible;116use sp_runtime::traits::CheckedConversion;117118use unique_runtime_common::{119 impl_common_runtime_apis,120 types::*,121 constants::*,122 dispatch::{CollectionDispatchT, CollectionDispatch},123 sponsoring::UniqueSponsorshipHandler,124 eth_sponsoring::UniqueEthSponsorshipHandler,125 weights::CommonWeights,126};127128pub const RUNTIME_NAME: &str = "opal";129pub const TOKEN_SYMBOL: &str = "OPL";130131type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;132133impl RuntimeInstance for Runtime {134 type CrossAccountId = self::CrossAccountId;135 type TransactionConverter = self::TransactionConverter;136137 fn get_transaction_converter() -> TransactionConverter {138 TransactionConverter139 }140}141142/// The type for looking up accounts. We don't expect more than 4 billion of them, but you143/// never know...144pub type AccountIndex = u32;145146/// Balance of an account.147pub type Balance = u128;148149/// Index of a transaction in the chain.150pub type Index = u32;151152/// A hash of some data used by the chain.153pub type Hash = sp_core::H256;154155/// Digest item type.156pub type DigestItem = generic::DigestItem;157158/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know159/// the specifics of the runtime. They can then be made to be agnostic over specific formats160/// of data like extrinsics, allowing for them to continue syncing the network through upgrades161/// to even the core data structures.162pub mod opaque {163 use sp_std::prelude::*;164 use sp_runtime::impl_opaque_keys;165 use super::Aura;166167 pub use unique_runtime_common::types::*;168169 impl_opaque_keys! {170 pub struct SessionKeys {171 pub aura: Aura,172 }173 }174}175176/// This runtime version.177pub const VERSION: RuntimeVersion = RuntimeVersion {178 spec_name: create_runtime_str!(RUNTIME_NAME),179 impl_name: create_runtime_str!(RUNTIME_NAME),180 authoring_version: 1,181 spec_version: 920000,182 impl_version: 0,183 apis: RUNTIME_API_VERSIONS,184 transaction_version: 1,185 state_version: 0,186};187188#[derive(codec::Encode, codec::Decode)]189pub enum XCMPMessage<XAccountId, XBalance> {190 /// Transfer tokens to the given account from the Parachain account.191 TransferToken(XAccountId, XBalance),192}193194/// The version information used to identify this runtime when compiled natively.195#[cfg(feature = "std")]196pub fn native_version() -> NativeVersion {197 NativeVersion {198 runtime_version: VERSION,199 can_author_with: Default::default(),200 }201}202203type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;204205pub struct DealWithFees;206impl OnUnbalanced<NegativeImbalance> for DealWithFees {207 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {208 if let Some(fees) = fees_then_tips.next() {209 // for fees, 100% to treasury210 let mut split = fees.ration(100, 0);211 if let Some(tips) = fees_then_tips.next() {212 // for tips, if any, 100% to treasury213 tips.ration_merge_into(100, 0, &mut split);214 }215 Treasury::on_unbalanced(split.0);216 // Author::on_unbalanced(split.1);217 }218 }219}220221parameter_types! {222 pub const BlockHashCount: BlockNumber = 2400;223 pub RuntimeBlockLength: BlockLength =224 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);225 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);226 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;227 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()228 .base_block(BlockExecutionWeight::get())229 .for_class(DispatchClass::all(), |weights| {230 weights.base_extrinsic = ExtrinsicBaseWeight::get();231 })232 .for_class(DispatchClass::Normal, |weights| {233 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);234 })235 .for_class(DispatchClass::Operational, |weights| {236 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);237 // Operational transactions have some extra reserved space, so that they238 // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.239 weights.reserved = Some(240 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT241 );242 })243 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)244 .build_or_panic();245 pub const Version: RuntimeVersion = VERSION;246 pub const SS58Prefix: u8 = 42;247}248249parameter_types! {250 pub const ChainId: u64 = 8882;251}252253pub struct FixedFee;254impl FeeCalculator for FixedFee {255 fn min_gas_price() -> U256 {256 MIN_GAS_PRICE.into()257 }258}259260// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case261// (contract, which only writes a lot of data),262// approximating on top of our real store write weight263parameter_types! {264 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;265 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;266 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();267}268269/// Limiting EVM execution to 50% of block for substrate users and management tasks270/// EVM transaction consumes more weight than substrate's, so we can't rely on them being271/// scheduled fairly272const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);273parameter_types! {274 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());275}276277pub enum FixedGasWeightMapping {}278impl GasWeightMapping for FixedGasWeightMapping {279 fn gas_to_weight(gas: u64) -> Weight {280 gas.saturating_mul(WeightPerGas::get())281 }282 fn weight_to_gas(weight: Weight) -> u64 {283 weight / WeightPerGas::get()284 }285}286287impl pallet_evm::account::Config for Runtime {288 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;289 type EvmAddressMapping = pallet_evm::HashedAddressMapping<Self::Hashing>;290 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;291}292293impl pallet_evm::Config for Runtime {294 type BlockGasLimit = BlockGasLimit;295 type FeeCalculator = FixedFee;296 type GasWeightMapping = FixedGasWeightMapping;297 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;298 type CallOrigin = EnsureAddressTruncated<Self>;299 type WithdrawOrigin = EnsureAddressTruncated<Self>;300 type AddressMapping = HashedAddressMapping<Self::Hashing>;301 type PrecompilesType = ();302 type PrecompilesValue = ();303 type Currency = Balances;304 type Event = Event;305 type OnMethodCall = (306 pallet_evm_migration::OnMethodCall<Self>,307 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,308 CollectionDispatchT<Self>,309 pallet_evm_collection::CollectionOnMethodCall<Self>,310 );311 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;312 type ChainId = ChainId;313 type Runner = pallet_evm::runner::stack::Runner<Self>;314 type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;315 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;316 type FindAuthor = EthereumFindAuthor<Aura>;317}318319impl pallet_evm_migration::Config for Runtime {320 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;321}322323pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);324impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {325 fn find_author<'a, I>(digests: I) -> Option<H160>326 where327 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,328 {329 if let Some(author_index) = F::find_author(digests) {330 let authority_id = Aura::authorities()[author_index as usize].clone();331 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));332 }333 None334 }335}336337impl pallet_ethereum::Config for Runtime {338 type Event = Event;339 type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;340}341342impl pallet_randomness_collective_flip::Config for Runtime {}343344impl frame_system::Config for Runtime {345 /// The data to be stored in an account.346 type AccountData = pallet_balances::AccountData<Balance>;347 /// The identifier used to distinguish between accounts.348 type AccountId = AccountId;349 /// The basic call filter to use in dispatchable.350 type BaseCallFilter = Everything;351 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).352 type BlockHashCount = BlockHashCount;353 /// The maximum length of a block (in bytes).354 type BlockLength = RuntimeBlockLength;355 /// The index type for blocks.356 type BlockNumber = BlockNumber;357 /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.358 type BlockWeights = RuntimeBlockWeights;359 /// The aggregated dispatch type that is available for extrinsics.360 type Call = Call;361 /// The weight of database operations that the runtime can invoke.362 type DbWeight = RocksDbWeight;363 /// The ubiquitous event type.364 type Event = Event;365 /// The type for hashing blocks and tries.366 type Hash = Hash;367 /// The hashing algorithm used.368 type Hashing = BlakeTwo256;369 /// The header type.370 type Header = generic::Header<BlockNumber, BlakeTwo256>;371 /// The index type for storing how many extrinsics an account has signed.372 type Index = Index;373 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.374 type Lookup = AccountIdLookup<AccountId, ()>;375 /// What to do if an account is fully reaped from the system.376 type OnKilledAccount = ();377 /// What to do if a new account is created.378 type OnNewAccount = ();379 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;380 /// The ubiquitous origin type.381 type Origin = Origin;382 /// This type is being generated by `construct_runtime!`.383 type PalletInfo = PalletInfo;384 /// This is used as an identifier of the chain. 42 is the generic substrate prefix.385 type SS58Prefix = SS58Prefix;386 /// Weight information for the extrinsics of this pallet.387 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;388 /// Version of the runtime.389 type Version = Version;390 type MaxConsumers = ConstU32<16>;391}392393parameter_types! {394 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;395}396397impl pallet_timestamp::Config for Runtime {398 /// A timestamp: milliseconds since the unix epoch.399 type Moment = u64;400 type OnTimestampSet = ();401 type MinimumPeriod = MinimumPeriod;402 type WeightInfo = ();403}404405parameter_types! {406 // pub const ExistentialDeposit: u128 = 500;407 pub const ExistentialDeposit: u128 = 0;408 pub const MaxLocks: u32 = 50;409}410411impl pallet_balances::Config for Runtime {412 type MaxLocks = MaxLocks;413 type MaxReserves = ();414 type ReserveIdentifier = [u8; 8];415 /// The type for recording an account's balance.416 type Balance = Balance;417 /// The ubiquitous event type.418 type Event = Event;419 type DustRemoval = Treasury;420 type ExistentialDeposit = ExistentialDeposit;421 type AccountStore = System;422 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;423}424425pub const fn deposit(items: u32, bytes: u32) -> Balance {426 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE427}428429/*430parameter_types! {431 pub TombstoneDeposit: Balance = deposit(432 1,433 sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,434 );435 pub DepositPerContract: Balance = TombstoneDeposit::get();436 pub const DepositPerStorageByte: Balance = deposit(0, 1);437 pub const DepositPerStorageItem: Balance = deposit(1, 0);438 pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);439 pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;440 pub const SignedClaimHandicap: u32 = 2;441 pub const MaxDepth: u32 = 32;442 pub const MaxValueSize: u32 = 16 * 1024;443 pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb444 // The lazy deletion runs inside on_initialize.445 pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *446 RuntimeBlockWeights::get().max_block;447 // The weight needed for decoding the queue should be less or equal than a fifth448 // of the overall weight dedicated to the lazy deletion.449 pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (450 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -451 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)452 )) / 5) as u32;453 pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();454}455456impl pallet_contracts::Config for Runtime {457 type Time = Timestamp;458 type Randomness = RandomnessCollectiveFlip;459 type Currency = Balances;460 type Event = Event;461 type RentPayment = ();462 type SignedClaimHandicap = SignedClaimHandicap;463 type TombstoneDeposit = TombstoneDeposit;464 type DepositPerContract = DepositPerContract;465 type DepositPerStorageByte = DepositPerStorageByte;466 type DepositPerStorageItem = DepositPerStorageItem;467 type RentFraction = RentFraction;468 type SurchargeReward = SurchargeReward;469 type WeightPrice = pallet_transaction_payment::Pallet<Self>;470 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;471 type ChainExtension = NFTExtension;472 type DeletionQueueDepth = DeletionQueueDepth;473 type DeletionWeightLimit = DeletionWeightLimit;474 type Schedule = Schedule;475 type CallStack = [pallet_contracts::Frame<Self>; 31];476}477*/478479parameter_types! {480 /// This value increases the priority of `Operational` transactions by adding481 /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.482 pub const OperationalFeeMultiplier: u8 = 5;483}484485/// Linear implementor of `WeightToFeePolynomial`486pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);487488impl<T> WeightToFeePolynomial for LinearFee<T>489where490 T: BaseArithmetic + From<u32> + Copy + Unsigned,491{492 type Balance = T;493494 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {495 smallvec!(WeightToFeeCoefficient {496 // Targeting 0.1 Unique per NFT transfer497 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),498 coeff_frac: Perbill::zero(),499 negative: false,500 degree: 1,501 })502 }503}504505impl pallet_transaction_payment::Config for Runtime {506 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;507 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;508 type OperationalFeeMultiplier = OperationalFeeMultiplier;509 type WeightToFee = LinearFee<Balance>;510 type FeeMultiplierUpdate = ();511}512513parameter_types! {514 pub const ProposalBond: Permill = Permill::from_percent(5);515 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;516 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;517 pub const SpendPeriod: BlockNumber = 5 * MINUTES;518 pub const Burn: Permill = Permill::from_percent(0);519 pub const TipCountdown: BlockNumber = 1 * DAYS;520 pub const TipFindersFee: Percent = Percent::from_percent(20);521 pub const TipReportDepositBase: Balance = 1 * UNIQUE;522 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;523 pub const BountyDepositBase: Balance = 1 * UNIQUE;524 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;525 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");526 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;527 pub const MaximumReasonLength: u32 = 16384;528 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);529 pub const BountyValueMinimum: Balance = 5 * UNIQUE;530 pub const MaxApprovals: u32 = 100;531}532533impl pallet_treasury::Config for Runtime {534 type PalletId = TreasuryModuleId;535 type Currency = Balances;536 type ApproveOrigin = EnsureRoot<AccountId>;537 type RejectOrigin = EnsureRoot<AccountId>;538 type Event = Event;539 type OnSlash = ();540 type ProposalBond = ProposalBond;541 type ProposalBondMinimum = ProposalBondMinimum;542 type ProposalBondMaximum = ProposalBondMaximum;543 type SpendPeriod = SpendPeriod;544 type Burn = Burn;545 type BurnDestination = ();546 type SpendFunds = ();547 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;548 type MaxApprovals = MaxApprovals;549}550551impl pallet_sudo::Config for Runtime {552 type Event = Event;553 type Call = Call;554}555556pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);557558impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider559 for RelayChainBlockNumberProvider<T>560{561 type BlockNumber = BlockNumber;562563 fn current_block_number() -> Self::BlockNumber {564 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()565 .map(|d| d.relay_parent_number)566 .unwrap_or_default()567 }568}569570parameter_types! {571 pub const MinVestedTransfer: Balance = 10 * UNIQUE;572 pub const MaxVestingSchedules: u32 = 28;573}574575impl orml_vesting::Config for Runtime {576 type Event = Event;577 type Currency = pallet_balances::Pallet<Runtime>;578 type MinVestedTransfer = MinVestedTransfer;579 type VestedTransferOrigin = EnsureSigned<AccountId>;580 type WeightInfo = ();581 type MaxVestingSchedules = MaxVestingSchedules;582 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;583}584585parameter_types! {586 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;587 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;588}589590impl cumulus_pallet_parachain_system::Config for Runtime {591 type Event = Event;592 type SelfParaId = parachain_info::Pallet<Self>;593 type OnSystemEvent = ();594 // type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<595 // MaxDownwardMessageWeight,596 // XcmExecutor<XcmConfig>,597 // Call,598 // >;599 type OutboundXcmpMessageSource = XcmpQueue;600 type DmpMessageHandler = DmpQueue;601 type ReservedDmpWeight = ReservedDmpWeight;602 type ReservedXcmpWeight = ReservedXcmpWeight;603 type XcmpMessageHandler = XcmpQueue;604}605606impl parachain_info::Config for Runtime {}607608impl cumulus_pallet_aura_ext::Config for Runtime {}609610parameter_types! {611 pub const RelayLocation: MultiLocation = MultiLocation::parent();612 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;613 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();614 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();615}616617/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used618/// when determining ownership of accounts for asset transacting and when attempting to use XCM619/// `Transact` in order to determine the dispatch Origin.620pub type LocationToAccountId = (621 // The parent (Relay-chain) origin converts to the default `AccountId`.622 ParentIsPreset<AccountId>,623 // Sibling parachain origins convert to AccountId via the `ParaId::into`.624 SiblingParachainConvertsVia<Sibling, AccountId>,625 // Straight up local `AccountId32` origins just alias directly to `AccountId`.626 AccountId32Aliases<RelayNetwork, AccountId>,627);628629pub struct OnlySelfCurrency;630impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {631 fn matches_fungible(a: &MultiAsset) -> Option<B> {632 match (&a.id, &a.fun) {633 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),634 _ => None,635 }636 }637}638639/// Means for transacting assets on this chain.640pub type LocalAssetTransactor = CurrencyAdapter<641 // Use this currency:642 Balances,643 // Use this currency when it is a fungible asset matching the given location or name:644 OnlySelfCurrency,645 // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:646 LocationToAccountId,647 // Our chain's account ID type (we can't get away without mentioning it explicitly):648 AccountId,649 // We don't track any teleports.650 (),651>;652653/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,654/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can655/// biases the kind of local `Origin` it will become.656pub type XcmOriginToTransactDispatchOrigin = (657 // Sovereign account converter; this attempts to derive an `AccountId` from the origin location658 // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for659 // foreign chains who want to have a local sovereign account on this chain which they control.660 SovereignSignedViaLocation<LocationToAccountId, Origin>,661 // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when662 // recognised.663 RelayChainAsNative<RelayOrigin, Origin>,664 // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when665 // recognised.666 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,667 // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a668 // transaction from the Root origin.669 ParentAsSuperuser<Origin>,670 // Native signed account converter; this just converts an `AccountId32` origin into a normal671 // `Origin::Signed` origin of the same 32-byte value.672 SignedAccountId32AsNative<RelayNetwork, Origin>,673 // Xcm origins can be represented natively under the Xcm pallet's Xcm origin.674 XcmPassthrough<Origin>,675);676677parameter_types! {678 // One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.679 pub UnitWeightCost: Weight = 1_000_000;680 // 1200 UNIQUEs buy 1 second of weight.681 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);682 pub const MaxInstructions: u32 = 100;683 pub const MaxAuthorities: u32 = 100_000;684}685686match_types! {687 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {688 MultiLocation { parents: 1, interior: Here } |689 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }690 };691}692693pub type Barrier = (694 TakeWeightCredit,695 AllowTopLevelPaidExecutionFrom<Everything>,696 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,697 // ^^^ Parent & its unit plurality gets free execution698);699700pub struct UsingOnlySelfCurrencyComponents<701 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,702 AssetId: Get<MultiLocation>,703 AccountId,704 Currency: CurrencyT<AccountId>,705 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,706>(707 Weight,708 Currency::Balance,709 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,710);711impl<712 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,713 AssetId: Get<MultiLocation>,714 AccountId,715 Currency: CurrencyT<AccountId>,716 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,717 > WeightTrader718 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>719{720 fn new() -> Self {721 Self(0, Zero::zero(), PhantomData)722 }723724 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {725 let amount = WeightToFee::calc(&weight);726 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;727728 // location to this parachain through relay chain729 let option1: xcm::v1::AssetId = Concrete(MultiLocation {730 parents: 1,731 interior: X1(Parachain(ParachainInfo::parachain_id().into())),732 });733 // direct location734 let option2: xcm::v1::AssetId = Concrete(MultiLocation {735 parents: 0,736 interior: Here,737 });738739 let required = if payment.fungible.contains_key(&option1) {740 (option1, u128_amount).into()741 } else if payment.fungible.contains_key(&option2) {742 (option2, u128_amount).into()743 } else {744 (Concrete(MultiLocation::default()), u128_amount).into()745 };746747 let unused = payment748 .checked_sub(required)749 .map_err(|_| XcmError::TooExpensive)?;750 self.0 = self.0.saturating_add(weight);751 self.1 = self.1.saturating_add(amount);752 Ok(unused)753 }754755 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {756 let weight = weight.min(self.0);757 let amount = WeightToFee::calc(&weight);758 self.0 -= weight;759 self.1 = self.1.saturating_sub(amount);760 let amount: u128 = amount.saturated_into();761 if amount > 0 {762 Some((AssetId::get(), amount).into())763 } else {764 None765 }766 }767}768impl<769 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,770 AssetId: Get<MultiLocation>,771 AccountId,772 Currency: CurrencyT<AccountId>,773 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,774 > Drop775 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>776{777 fn drop(&mut self) {778 OnUnbalanced::on_unbalanced(Currency::issue(self.1));779 }780}781782pub struct XcmConfig;783impl Config for XcmConfig {784 type Call = Call;785 type XcmSender = XcmRouter;786 // How to withdraw and deposit an asset.787 type AssetTransactor = LocalAssetTransactor;788 type OriginConverter = XcmOriginToTransactDispatchOrigin;789 type IsReserve = NativeAsset;790 type IsTeleporter = (); // Teleportation is disabled791 type LocationInverter = LocationInverter<Ancestry>;792 type Barrier = Barrier;793 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;794 type Trader = UsingOnlySelfCurrencyComponents<795 IdentityFee<Balance>,796 RelayLocation,797 AccountId,798 Balances,799 (),800 >;801 type ResponseHandler = (); // Don't handle responses for now.802 type SubscriptionService = PolkadotXcm;803804 type AssetTrap = PolkadotXcm;805 type AssetClaims = PolkadotXcm;806}807808// parameter_types! {809// pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;810// }811812/// No local origins on this chain are allowed to dispatch XCM sends/executions.813pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);814815/// The means for routing XCM messages which are not for local execution into the right message816/// queues.817pub type XcmRouter = (818 // Two routers - use UMP to communicate with the relay chain:819 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,820 // ..and XCMP to communicate with the sibling chains.821 XcmpQueue,822);823824impl pallet_evm_coder_substrate::Config for Runtime {825 type GasWeightMapping = FixedGasWeightMapping;826}827828impl pallet_xcm::Config for Runtime {829 type Event = Event;830 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;831 type XcmRouter = XcmRouter;832 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;833 type XcmExecuteFilter = Everything;834 type XcmExecutor = XcmExecutor<XcmConfig>;835 type XcmTeleportFilter = Everything;836 type XcmReserveTransferFilter = Everything;837 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;838 type LocationInverter = LocationInverter<Ancestry>;839 type Origin = Origin;840 type Call = Call;841 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;842 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;843}844845impl cumulus_pallet_xcm::Config for Runtime {846 type Event = Event;847 type XcmExecutor = XcmExecutor<XcmConfig>;848}849850impl cumulus_pallet_xcmp_queue::Config for Runtime {851 type WeightInfo = ();852 type Event = Event;853 type XcmExecutor = XcmExecutor<XcmConfig>;854 type ChannelInfo = ParachainSystem;855 type VersionWrapper = ();856 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;857 type ControllerOrigin = EnsureRoot<AccountId>;858 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;859}860861impl cumulus_pallet_dmp_queue::Config for Runtime {862 type Event = Event;863 type XcmExecutor = XcmExecutor<XcmConfig>;864 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;865}866867impl pallet_aura::Config for Runtime {868 type AuthorityId = AuraId;869 type DisabledValidators = ();870 type MaxAuthorities = MaxAuthorities;871}872873parameter_types! {874 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();875 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;876}877878impl pallet_common::Config for Runtime {879 type WeightInfo = pallet_common::weights::SubstrateWeight<Self>;880 type Event = Event;881 type Currency = Balances;882 type CollectionCreationPrice = CollectionCreationPrice;883 type TreasuryAccountId = TreasuryAccountId;884 type CollectionDispatch = CollectionDispatchT<Self>;885886 type EvmTokenAddressMapping = EvmTokenAddressMapping;887 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;888}889890impl pallet_structure::Config for Runtime {891 type Event = Event;892 type Call = Call;893 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;894}895896impl pallet_fungible::Config for Runtime {897 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;898}899impl pallet_refungible::Config for Runtime {900 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;901}902impl pallet_nonfungible::Config for Runtime {903 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;904}905906impl pallet_proxy_rmrk_core::Config for Runtime {907 type Event = Event;908}909910impl pallet_proxy_rmrk_equip::Config for Runtime {911 type Event = Event;912}913914impl pallet_unique::Config for Runtime {915 type Event = Event;916 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;917 type CommonWeightInfo = CommonWeights<Self>;918}919920parameter_types! {921 pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied922}923924/// Used for the pallet inflation925impl pallet_inflation::Config for Runtime {926 type Currency = Balances;927 type TreasuryAccountId = TreasuryAccountId;928 type InflationBlockInterval = InflationBlockInterval;929 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;930}931932// parameter_types! {933// pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *934// RuntimeBlockWeights::get().max_block;935// pub const MaxScheduledPerBlock: u32 = 50;936// }937938type EvmSponsorshipHandler = (939 UniqueEthSponsorshipHandler<Runtime>,940 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,941);942type SponsorshipHandler = (943 UniqueSponsorshipHandler<Runtime>,944 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,945 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,946);947948// impl pallet_unq_scheduler::Config for Runtime {949// type Event = Event;950// type Origin = Origin;951// type PalletsOrigin = OriginCaller;952// type Call = Call;953// type MaximumWeight = MaximumSchedulerWeight;954// type ScheduleOrigin = EnsureSigned<AccountId>;955// type MaxScheduledPerBlock = MaxScheduledPerBlock;956// type SponsorshipHandler = SponsorshipHandler;957// type WeightInfo = ();958// }959960impl pallet_evm_transaction_payment::Config for Runtime {961 type EvmSponsorshipHandler = EvmSponsorshipHandler;962 type Currency = Balances;963}964965impl pallet_charge_transaction::Config for Runtime {966 type SponsorshipHandler = SponsorshipHandler;967}968969// impl pallet_contract_helpers::Config for Runtime {970// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;971// }972973parameter_types! {974 // 0x842899ECF380553E8a4de75bF534cdf6fBF64049975 pub const HelpersContractAddress: H160 = H160([976 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,977 ]);978 979 // 0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f980 pub const EvmCollectionAddress: H160 = H160([981 0x6c, 0x4e, 0x9f, 0xe1, 0xae, 0x37, 0xa4, 0x1e, 0x93, 0xce, 0xe4, 0x29, 0xe8, 0xe1, 0x88, 0x1a, 0xbd, 0xcb, 0xb5, 0x4f,982 ]);983}984985impl pallet_evm_contract_helpers::Config for Runtime {986 type ContractAddress = HelpersContractAddress;987 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;988}989990impl pallet_evm_collection::Config for Runtime {991 type ContractAddress = EvmCollectionAddress;992}993994construct_runtime!(995 pub enum Runtime where996 Block = Block,997 NodeBlock = opaque::Block,998 UncheckedExtrinsic = UncheckedExtrinsic999 {1000 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,1001 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,10021003 Aura: pallet_aura::{Pallet, Config<T>} = 22,1004 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,10051006 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,1007 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,1008 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,1009 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,1010 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,1011 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,1012 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,1013 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,1014 // Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,1015 // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,10161017 // XCM helpers.1018 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,1019 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,1020 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,1021 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,10221023 // Unique Pallets1024 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,1025 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,1026 // Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,1027 // free = 631028 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,1029 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,1030 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,1031 Fungible: pallet_fungible::{Pallet, Storage} = 67,1032 Refungible: pallet_refungible::{Pallet, Storage} = 68,1033 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1034 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1035 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,1036 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,10371038 // Frontier1039 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1040 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,10411042 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1043 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1044 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1045 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1046 EvmCollection: pallet_evm_collection::{Pallet} = 154,1047 }1048);10491050pub struct TransactionConverter;10511052impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1053 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1054 UncheckedExtrinsic::new_unsigned(1055 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1056 )1057 }1058}10591060impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1061 fn convert_transaction(1062 &self,1063 transaction: pallet_ethereum::Transaction,1064 ) -> opaque::UncheckedExtrinsic {1065 let extrinsic = UncheckedExtrinsic::new_unsigned(1066 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1067 );1068 let encoded = extrinsic.encode();1069 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1070 .expect("Encoded extrinsic is always valid")1071 }1072}10731074/// The address format for describing accounts.1075pub type Address = sp_runtime::MultiAddress<AccountId, ()>;1076/// Block header type as expected by this runtime.1077pub type Header = generic::Header<BlockNumber, BlakeTwo256>;1078/// Block type as expected by this runtime.1079pub type Block = generic::Block<Header, UncheckedExtrinsic>;1080/// A Block signed with a Justification1081pub type SignedBlock = generic::SignedBlock<Block>;1082/// BlockId type as expected by this runtime.1083pub type BlockId = generic::BlockId<Block>;1084/// The SignedExtension to the basic transaction logic.1085pub type SignedExtra = (1086 frame_system::CheckSpecVersion<Runtime>,1087 // system::CheckTxVersion<Runtime>,1088 frame_system::CheckGenesis<Runtime>,1089 frame_system::CheckEra<Runtime>,1090 frame_system::CheckNonce<Runtime>,1091 frame_system::CheckWeight<Runtime>,1092 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1093 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,1094 pallet_ethereum::FakeTransactionFinalizer<Runtime>,1095);1096/// Unchecked extrinsic type as expected by this runtime.1097pub type UncheckedExtrinsic =1098 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;1099/// Extrinsic type that has already been checked.1100pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;1101/// Executive: handles dispatch to the various modules.1102pub type Executive = frame_executive::Executive<1103 Runtime,1104 Block,1105 frame_system::ChainContext<Runtime>,1106 Runtime,1107 AllPalletsReversedWithSystemFirst,1108>;11091110impl_opaque_keys! {1111 pub struct SessionKeys {1112 pub aura: Aura,1113 }1114}11151116impl fp_self_contained::SelfContainedCall for Call {1117 type SignedInfo = H160;11181119 fn is_self_contained(&self) -> bool {1120 match self {1121 Call::Ethereum(call) => call.is_self_contained(),1122 _ => false,1123 }1124 }11251126 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1127 match self {1128 Call::Ethereum(call) => call.check_self_contained(),1129 _ => None,1130 }1131 }11321133 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1134 match self {1135 Call::Ethereum(call) => call.validate_self_contained(info),1136 _ => None,1137 }1138 }11391140 fn pre_dispatch_self_contained(1141 &self,1142 info: &Self::SignedInfo,1143 ) -> Option<Result<(), TransactionValidityError>> {1144 match self {1145 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1146 _ => None,1147 }1148 }11491150 fn apply_self_contained(1151 self,1152 info: Self::SignedInfo,1153 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1154 match self {1155 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1156 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1157 )),1158 _ => None,1159 }1160 }1161}11621163macro_rules! dispatch_unique_runtime {1164 ($collection:ident.$method:ident($($name:ident),*)) => {{1165 let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1166 let dispatch = collection.as_dyn();11671168 Ok::<_, DispatchError>(dispatch.$method($($name),*))1169 }};1170}11711172impl_common_runtime_apis!();11731174struct CheckInherents;11751176impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1177 fn check_inherents(1178 block: &Block,1179 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1180 ) -> sp_inherents::CheckInherentsResult {1181 let relay_chain_slot = relay_state_proof1182 .read_slot()1183 .expect("Could not read the relay chain slot from the proof");11841185 let inherent_data =1186 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1187 relay_chain_slot,1188 sp_std::time::Duration::from_secs(6),1189 )1190 .create_inherent_data()1191 .expect("Could not create the timestamp inherent data");11921193 inherent_data.check_extrinsics(block)1194 }1195}11961197cumulus_pallet_parachain_system::register_validate_block!(1198 Runtime = Runtime,1199 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1200 CheckInherents = CheckInherents,1201);runtime/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" }
runtime/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,
}
);
runtime/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" }
runtime/unique/src/lib.rsdiffbeforeafterboth--- a/runtime/unique/src/lib.rs
+++ b/runtime/unique/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,
@@ -282,6 +282,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;
@@ -956,6 +957,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 {
@@ -963,6 +969,10 @@
type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;
}
+impl pallet_evm_collection::Config for Runtime {
+ type ContractAddress = EvmCollectionAddress;
+}
+
construct_runtime!(
pub enum Runtime where
Block = Block,
@@ -1015,6 +1025,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,
}
);
tests/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);
+}
tests/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);
}
tests/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"
+ }
+]
tests/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';
tests/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",
tests/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