difftreelog
CORE-300 Adapt to CrossAccountId
in: master
20 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2554,7 +2554,7 @@
"fc-db",
"fc-rpc-core",
"fp-consensus",
- "fp-evm 3.0.0-dev (git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.17)",
+ "fp-evm",
"fp-rpc",
"fp-storage",
"futures 0.3.21",
@@ -2565,7 +2565,7 @@
"log",
"lru 0.6.6",
"pallet-ethereum",
- "pallet-evm 6.0.0-dev (git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.17)",
+ "pallet-evm",
"parity-scale-codec",
"parking_lot 0.11.2",
"rand 0.7.3",
@@ -2757,7 +2757,7 @@
dependencies = [
"ethereum",
"ethereum-types",
- "fp-evm 3.0.0-dev (git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.17)",
+ "fp-evm",
"parity-scale-codec",
"scale-info",
"sp-api",
@@ -2853,21 +2853,6 @@
]
[[package]]
-name = "frame-common"
-version = "0.1.0"
-source = "git+https://github.com/uniquenetwork/frontier.git?branch=feature/300#0a1dc4086cbe971ddf57edf82a61cfce52c8c20b"
-dependencies = [
- "frame-system",
- "pallet-evm 6.0.0-dev (git+https://github.com/uniquenetwork/frontier.git?branch=feature/300)",
- "parity-scale-codec",
- "scale-info",
- "serde",
- "sp-core",
- "sp-std",
- "up-evm-mapping",
-]
-
-[[package]]
name = "frame-election-provider-support"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.18#fc3fd073d3a0acf9933c3994b660ebd7b5833f65"
@@ -5850,7 +5835,7 @@
dependencies = [
"frame-support",
"frame-system",
- "pallet-evm 6.0.0-dev (git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.17)",
+ "pallet-evm",
"parity-scale-codec",
"scale-info",
"serde",
@@ -5999,10 +5984,9 @@
version = "0.1.0"
dependencies = [
"evm-coder",
- "frame-common",
"frame-support",
"frame-system",
- "pallet-evm 6.0.0-dev (git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.17)",
+ "pallet-evm",
"pallet-evm-coder-substrate",
"parity-scale-codec",
"scale-info",
@@ -6080,7 +6064,7 @@
"ethereum-types",
"evm",
"fp-consensus",
- "fp-evm 3.0.0-dev (git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.17)",
+ "fp-evm",
"fp-rpc",
"fp-self-contained",
"fp-storage",
@@ -6088,7 +6072,7 @@
"frame-system",
"log",
"pallet-balances",
- "pallet-evm 6.0.0-dev (git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.17)",
+ "pallet-evm",
"pallet-timestamp",
"parity-scale-codec",
"rlp",
@@ -6109,7 +6093,7 @@
"evm",
"evm-gasometer",
"evm-runtime",
- "fp-evm 3.0.0-dev (git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.17)",
+ "fp-evm",
"frame-benchmarking",
"frame-support",
"frame-system",
@@ -6140,7 +6124,7 @@
"frame-support",
"frame-system",
"pallet-ethereum",
- "pallet-evm 6.0.0-dev (git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.17)",
+ "pallet-evm",
"parity-scale-codec",
"scale-info",
"sp-core",
@@ -6155,7 +6139,7 @@
"frame-support",
"frame-system",
"log",
- "pallet-evm 6.0.0-dev (git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.17)",
+ "pallet-evm",
"pallet-evm-coder-substrate",
"parity-scale-codec",
"scale-info",
@@ -6170,11 +6154,11 @@
name = "pallet-evm-migration"
version = "0.1.0"
dependencies = [
- "fp-evm 3.0.0-dev (git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.17)",
+ "fp-evm",
"frame-benchmarking",
"frame-support",
"frame-system",
- "pallet-evm 6.0.0-dev (git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.17)",
+ "pallet-evm",
"parity-scale-codec",
"scale-info",
"sp-core",
@@ -6187,11 +6171,11 @@
name = "pallet-evm-transaction-payment"
version = "0.1.0"
dependencies = [
- "fp-evm 3.0.0-dev (git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.17)",
+ "fp-evm",
"frame-support",
"frame-system",
"pallet-ethereum",
- "pallet-evm 6.0.0-dev (git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.17)",
+ "pallet-evm",
"parity-scale-codec",
"scale-info",
"sp-core",
@@ -6209,10 +6193,10 @@
"ethereum",
"evm-coder",
"frame-benchmarking",
- "frame-common",
"frame-support",
"frame-system",
"pallet-common",
+ "pallet-evm",
"pallet-evm-coder-substrate",
"parity-scale-codec",
"scale-info",
@@ -6436,10 +6420,10 @@
"ethereum",
"evm-coder",
"frame-benchmarking",
- "frame-common",
"frame-support",
"frame-system",
"pallet-common",
+ "pallet-evm",
"pallet-evm-coder-substrate",
"parity-scale-codec",
"scale-info",
@@ -6553,10 +6537,10 @@
version = "0.1.0"
dependencies = [
"frame-benchmarking",
- "frame-common",
"frame-support",
"frame-system",
"pallet-common",
+ "pallet-evm",
"parity-scale-codec",
"scale-info",
"sp-core",
@@ -6814,16 +6798,15 @@
dependencies = [
"ethereum",
"evm-coder",
- "fp-evm 3.0.0-dev (git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.17)",
+ "fp-evm",
"frame-benchmarking",
- "frame-common",
"frame-support",
"frame-system",
"hex-literal",
"pallet-balances",
"pallet-common",
"pallet-ethereum",
- "pallet-evm 6.0.0-dev (git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.17)",
+ "pallet-evm",
"pallet-evm-coder-substrate",
"pallet-fungible",
"pallet-nonfungible",
@@ -12353,11 +12336,11 @@
name = "uc-rpc"
version = "0.1.0"
dependencies = [
- "frame-common",
"jsonrpc-core",
"jsonrpc-core-client",
"jsonrpc-derive",
"pallet-common",
+ "pallet-evm",
"parity-scale-codec",
"sp-api",
"sp-blockchain",
@@ -12570,7 +12553,6 @@
"fp-rpc",
"fp-self-contained",
"frame-benchmarking",
- "frame-common",
"frame-executive",
"frame-support",
"frame-system",
@@ -12583,7 +12565,7 @@
"pallet-base-fee",
"pallet-common",
"pallet-ethereum",
- "pallet-evm 6.0.0-dev (git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.17)",
+ "pallet-evm",
"pallet-evm-coder-substrate",
"pallet-evm-contract-helpers",
"pallet-evm-migration",
@@ -12720,8 +12702,8 @@
name = "up-rpc"
version = "0.1.0"
dependencies = [
- "frame-common",
"pallet-common",
+ "pallet-evm",
"parity-scale-codec",
"sp-api",
"sp-core",
client/rpc/Cargo.tomldiffbeforeafterboth--- a/client/rpc/Cargo.toml
+++ b/client/rpc/Cargo.toml
@@ -18,4 +18,5 @@
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.18" }
sp-rpc = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.18" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.18" }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.18" }
frame-common = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "feature/300" }
client/rpc/src/lib.rsdiffbeforeafterboth--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -201,7 +201,7 @@
AccountId: Decode,
C: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,
C::Api: UniqueRuntimeApi<Block, CrossAccountId, AccountId>,
- CrossAccountId: frame_common::account::CrossAccountId<AccountId>,
+ CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,
{
pass_method!(account_tokens(collection: CollectionId, account: CrossAccountId) -> Vec<TokenId>);
pass_method!(token_exists(collection: CollectionId, token: TokenId) -> bool);
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -19,7 +19,7 @@
use core::ops::{Deref, DerefMut};
use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
use sp_std::vec::Vec;
-use frame_common::account::CrossAccountId;
+use pallet_evm::account::CrossAccountId;
use frame_support::{
dispatch::{DispatchErrorWithPostInfo, DispatchResultWithPostInfo},
ensure, fail,
@@ -162,19 +162,14 @@
pub mod pallet {
use super::*;
use frame_support::{Blake2_128Concat, pallet_prelude::*, storage::Key};
- use frame_common::account::CrossAccountId;
+ use pallet_evm::account;
use frame_support::traits::Currency;
use up_data_structs::TokenId;
use scale_info::TypeInfo;
#[pallet::config]
- pub trait Config: frame_system::Config + pallet_evm_coder_substrate::Config + TypeInfo {
+ pub trait Config: frame_system::Config + pallet_evm_coder_substrate::Config + TypeInfo + account::Config {
type Event: IsType<<Self as frame_system::Config>::Event> + From<Event<Self>>;
-
- type CrossAccountId: CrossAccountId<Self::AccountId>;
-
- type EvmAddressMapping: pallet_evm::AddressMapping<Self::AccountId>;
- type EvmBackwardsAddressMapping: up_evm_mapping::EvmBackwardsAddressMapping<Self::AccountId>;
type Currency: Currency<Self::AccountId>;
pallets/evm-transaction-payment/src/lib.rsdiffbeforeafterboth--- a/pallets/evm-transaction-payment/src/lib.rs
+++ b/pallets/evm-transaction-payment/src/lib.rs
@@ -20,7 +20,7 @@
use fp_evm::WithdrawReason;
use frame_support::traits::{Currency, IsSubType};
pub use pallet::*;
-use pallet_evm::{EVMCurrencyAdapter, EnsureAddressOrigin};
+use pallet_evm::{EVMCurrencyAdapter, EnsureAddressOrigin, account::CrossAccountId};
use sp_core::{H160, U256};
use sp_runtime::TransactionOutcome;
use up_sponsorship::SponsorshipHandler;
@@ -35,11 +35,9 @@
use sp_std::vec::Vec;
#[pallet::config]
- pub trait Config: frame_system::Config {
+ pub trait Config: frame_system::Config + pallet_evm::account::Config {
type EvmSponsorshipHandler: SponsorshipHandler<Self::AccountId, (H160, Vec<u8>)>;
type Currency: Currency<Self::AccountId>;
- type EvmBackwardsAddressMapping: EvmBackwardsAddressMapping<Self::AccountId>;
- type EvmAddressMapping: AddressMapping<Self::AccountId>;
}
#[pallet::pallet]
@@ -86,14 +84,16 @@
type LiquidityInfo = Option<ChargeEvmLiquidityInfo<T>>;
fn withdraw_fee(
- who: &T::AccountId,
+ who: &T::CrossAccountId,
reason: WithdrawReason,
fee: U256,
) -> core::result::Result<Self::LiquidityInfo, pallet_evm::Error<T>> {
- let mut who_pays_fee = who.clone();
+ let who_pays_fee;
if let WithdrawReason::Call { target, input } = &reason {
- who_pays_fee = T::EvmSponsorshipHandler::get_sponsor(who, &(*target, input.clone()))
- .unwrap_or(who_pays_fee);
+ who_pays_fee = <T as pallet_evm::account::Config>::CrossAccountId::from_sub(T::EvmSponsorshipHandler::get_sponsor(&who.as_sub(), &(*target, input.clone()))
+ .unwrap_or(who.as_sub().clone()));
+ } else {
+ who_pays_fee = who.clone();
}
let negative_imbalance = EVMCurrencyAdapter::<<T as Config>::Currency, ()>::withdraw_fee(
@@ -102,20 +102,19 @@
fee,
)?;
- let who_pays_fee_eth = T::EvmBackwardsAddressMapping::from_account_id(who_pays_fee);
Ok(negative_imbalance.map(|i| ChargeEvmLiquidityInfo {
- who: who_pays_fee_eth,
+ who: who_pays_fee.as_eth().clone(),
negative_imbalance: i,
}))
}
fn correct_and_deposit_fee(
- who: &T::AccountId,
+ who: &T::CrossAccountId,
corrected_fee: U256,
already_withdrawn: Self::LiquidityInfo,
) {
<EVMCurrencyAdapter<<T as Config>::Currency, ()> as pallet_evm::OnChargeEVMTransaction<T>>::correct_and_deposit_fee(
- &already_withdrawn.as_ref().map(|e| T::EvmAddressMapping::into_account_id(e.who)).unwrap_or(who.clone()),
+ &already_withdrawn.as_ref().map(|e| T::CrossAccountId::from_eth(e.who)).unwrap_or(who.clone()),
corrected_fee,
already_withdrawn.map(|e| e.negative_imbalance),
)
pallets/fungible/Cargo.tomldiffbeforeafterboth--- a/pallets/fungible/Cargo.toml
+++ b/pallets/fungible/Cargo.toml
@@ -22,10 +22,10 @@
pallet-evm-coder-substrate = { default-features = false, path = '../evm-coder-substrate' }
ethereum = { version = "0.12.0", default-features = false }
frame-benchmarking = { default-features = false, optional = true, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.18' }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.18" }
scale-info = { version = "2.0.1", default-features = false, features = [
"derive",
] }
-frame-common = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "feature/300" }
[features]
default = ["std"]
@@ -40,5 +40,6 @@
"ethereum/std",
"pallet-evm-coder-substrate/std",
'frame-benchmarking/std',
+ "pallet-evm/std"
]
runtime-benchmarks = ['frame-benchmarking', 'pallet-common/runtime-benchmarks']
pallets/fungible/src/erc.rsdiffbeforeafterboth--- a/pallets/fungible/src/erc.rs
+++ b/pallets/fungible/src/erc.rs
@@ -21,7 +21,7 @@
use pallet_common::erc::{CommonEvmHandler, PrecompileResult};
use sp_core::{H160, U256};
use sp_std::vec::Vec;
-use frame_common::account::CrossAccountId;
+use pallet_evm::account::CrossAccountId;
use pallet_evm_coder_substrate::{call, dispatch_to_evm};
use crate::{
pallets/fungible/src/lib.rsdiffbeforeafterboth--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -22,7 +22,7 @@
use pallet_common::{
Error as CommonError, Event as CommonEvent, Pallet as PalletCommon,
};
-use frame_common::account::CrossAccountId;
+use pallet_evm::account::CrossAccountId;
use pallet_evm_coder_substrate::WithRecorder;
use sp_core::H160;
use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};
@@ -37,7 +37,7 @@
pub mod erc;
pub mod weights;
-pub type CreateItemData<T> = (<T as pallet_common::Config>::CrossAccountId, u128);
+pub type CreateItemData<T> = (<T as pallet_evm::account::Config>::CrossAccountId, u128);
pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;
#[frame_support::pallet]
pallets/nonfungible/Cargo.tomldiffbeforeafterboth--- a/pallets/nonfungible/Cargo.toml
+++ b/pallets/nonfungible/Cargo.toml
@@ -16,6 +16,7 @@
sp-runtime = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.18' }
sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.18' }
sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.18' }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.18" }
pallet-common = { default-features = false, path = '../common' }
up-data-structs = { default-features = false, path = '../../primitives/data-structs' }
evm-coder = { default-features = false, path = '../../crates/evm-coder' }
@@ -25,7 +26,6 @@
scale-info = { version = "2.0.1", default-features = false, features = [
"derive",
] }
-frame-common = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "feature/300" }
[features]
default = ["std"]
@@ -40,6 +40,7 @@
"ethereum/std",
"pallet-evm-coder-substrate/std",
'frame-benchmarking/std',
+ "pallet-evm/std"
]
runtime-benchmarks = [
'frame-benchmarking',
pallets/nonfungible/src/erc.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -27,7 +27,7 @@
use pallet_common::{
erc::{CommonEvmHandler, PrecompileResult},
};
-use frame_common::account::CrossAccountId;
+use pallet_evm::account::CrossAccountId;
use pallet_evm_coder_substrate::call;
use crate::{
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -24,7 +24,7 @@
use pallet_common::{
Error as CommonError, Pallet as PalletCommon, Event as CommonEvent,
};
-use frame_common::account::CrossAccountId;
+use pallet_evm::account::CrossAccountId;
use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
use sp_core::H160;
use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};
@@ -41,7 +41,7 @@
pub mod erc;
pub mod weights;
-pub type CreateItemData<T> = CreateNftExData<<T as pallet_common::Config>::CrossAccountId>;
+pub type CreateItemData<T> = CreateNftExData<<T as pallet_evm::account::Config>::CrossAccountId>;
pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;
#[derive(Encode, Decode, TypeInfo, MaxEncodedLen)]
pallets/refungible/Cargo.tomldiffbeforeafterboth--- a/pallets/refungible/Cargo.toml
+++ b/pallets/refungible/Cargo.toml
@@ -16,13 +16,13 @@
sp-runtime = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.18' }
sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.18' }
sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.18' }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.18" }
pallet-common = { default-features = false, path = '../common' }
up-data-structs = { default-features = false, path = '../../primitives/data-structs' }
frame-benchmarking = { default-features = false, optional = true, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.18' }
scale-info = { version = "2.0.1", default-features = false, features = [
"derive",
] }
-frame-common = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "feature/300" }
[features]
default = ["std"]
@@ -34,6 +34,7 @@
"up-data-structs/std",
"pallet-common/std",
'frame-benchmarking/std',
+ "pallet-evm/std",
]
runtime-benchmarks = [
'frame-benchmarking',
pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -24,7 +24,7 @@
use pallet_common::{
Error as CommonError, Event as CommonEvent, Pallet as PalletCommon,
};
-use frame_common::account::CrossAccountId;
+use pallet_evm::account::CrossAccountId;
use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};
use sp_std::{vec::Vec, vec, collections::btree_map::BTreeMap};
use core::ops::Deref;
pallets/unique/Cargo.tomldiffbeforeafterboth--- a/pallets/unique/Cargo.toml
+++ b/pallets/unique/Cargo.toml
@@ -133,7 +133,6 @@
up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring", branch = 'polkadot-v0.9.18' }
up-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "feature/300" }
-frame-common = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "feature/300" }
evm-coder = { default-features = false, path = "../../crates/evm-coder" }
pallet-evm-coder-substrate = { default-features = false, path = "../../pallets/evm-coder-substrate" }
primitive-types = { version = "0.11.1", default-features = false, features = [
pallets/unique/src/eth/sponsoring.rsdiffbeforeafterboth--- a/pallets/unique/src/eth/sponsoring.rs
+++ b/pallets/unique/src/eth/sponsoring.rs
@@ -25,7 +25,7 @@
use core::marker::PhantomData;
use core::convert::TryInto;
use up_data_structs::TokenId;
-use frame_common::account::CrossAccountId;
+use pallet_evm::account::CrossAccountId;
use pallet_nonfungible::erc::{UniqueNFTCall, ERC721UniqueExtensionsCall, ERC721Call};
use pallet_fungible::erc::{UniqueFungibleCall, ERC20Call};
pallets/unique/src/lib.rsdiffbeforeafterboth--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -57,7 +57,7 @@
CollectionHandle, Pallet as PalletCommon, Error as CommonError,
CommonWeightInfo,
};
-use frame_common::account::CrossAccountId;
+use pallet_evm::account::CrossAccountId;
use pallet_refungible::{Pallet as PalletRefungible, RefungibleHandle};
use pallet_fungible::{Pallet as PalletFungible, FungibleHandle};
use pallet_nonfungible::{Pallet as PalletNonfungible, NonfungibleHandle};
@@ -117,7 +117,7 @@
pub enum Event<T>
where
<T as frame_system::Config>::AccountId,
- <T as pallet_common::Config>::CrossAccountId,
+ <T as pallet_evm::account::Config>::CrossAccountId,
{
/// Collection sponsor was removed
///
pallets/unique/src/mock.rsdiffbeforeafterboth--- a/pallets/unique/src/mock.rs
+++ b/pallets/unique/src/mock.rs
@@ -27,7 +27,7 @@
use frame_system as system;
use pallet_evm::{AddressMapping, runner::stack::MaybeMirroredLog};
use up_evm_mapping::EvmBackwardsAddressMapping;
-use frame_common::account::CrossAccountId;
+use pallet_evm::account::CrossAccountId;
use codec::{Encode, Decode, MaxEncodedLen};
use scale_info::TypeInfo;
use up_data_structs::ConstU32;
@@ -192,15 +192,17 @@
impl pallet_common::Config for Test {
type Event = ();
- type EvmBackwardsAddressMapping = TestEvmBackwardsAddressMapping;
- type EvmAddressMapping = TestEvmAddressMapping;
- type CrossAccountId = TestCrossAccountId;
-
type Currency = Balances;
type CollectionCreationPrice = CollectionCreationPrice;
type TreasuryAccountId = TreasuryAccountId;
}
+impl pallet_evm::account::Config for Test {
+ type CrossAccountId = TestCrossAccountId;
+ type EvmAddressMapping = TestEvmAddressMapping;
+ type EvmBackwardsAddressMapping = TestEvmBackwardsAddressMapping;
+}
+
impl pallet_fungible::Config for Test {
type WeightInfo = ();
}
pallets/unique/src/sponsorship.rsdiffbeforeafterboth--- a/pallets/unique/src/sponsorship.rs
+++ b/pallets/unique/src/sponsorship.rs
@@ -30,7 +30,7 @@
NFT_SPONSOR_TRANSFER_TIMEOUT, REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, TokenId,
};
use pallet_common::{CollectionHandle};
-use frame_common::account::CrossAccountId;
+use pallet_evm::account::CrossAccountId;
pub fn withdraw_transfer<T: Config>(
collection: &CollectionHandle<T>,
primitives/rpc/src/lib.rsdiffbeforeafterboth--- a/primitives/rpc/src/lib.rs
+++ b/primitives/rpc/src/lib.rs
@@ -28,7 +28,7 @@
#[api_version(2)]
pub trait UniqueApi<CrossAccountId, AccountId> where
AccountId: Decode,
- CrossAccountId: frame_common::account::CrossAccountId<AccountId>,
+ CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,
{
#[changed_in(2)]
fn token_owner(collection: CollectionId, token: TokenId) -> Result<CrossAccountId>;
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::{EnsureAddressTruncated, HashedAddressMapping, Runner};52pub use frame_support::{53 construct_runtime, match_type,54 dispatch::DispatchResult,55 PalletId, parameter_types, StorageValue, ConsensusEngineId,56 traits::{57 tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,58 Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,59 OnUnbalanced, Randomness, FindAuthor,60 },61 weights::{62 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},63 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,64 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,65 },66};67use up_data_structs::*;68// use pallet_contracts::weights::WeightInfo;69// #[cfg(any(feature = "std", test))]70use frame_system::{71 self as frame_system, EnsureRoot, EnsureSigned,72 limits::{BlockWeights, BlockLength},73};74use sp_arithmetic::{75 traits::{BaseArithmetic, Unsigned},76};77use smallvec::smallvec;78use codec::{Encode, Decode};79use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping, OnMethodCall};80use fp_rpc::TransactionStatus;81use sp_runtime::{82 traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},83 transaction_validity::TransactionValidityError,84 SaturatedConversion,85};8687// pub use pallet_timestamp::Call as TimestampCall;88pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;8990// Polkadot imports91use pallet_xcm::XcmPassthrough;92use polkadot_parachain::primitives::Sibling;93use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};94use xcm_builder::{95 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,96 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,97 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,98 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,99 ParentIsPreset,100};101use xcm_executor::{Config, XcmExecutor, Assets};102use sp_std::{marker::PhantomData};103104use xcm::latest::{105 // Xcm,106 AssetId::{Concrete},107 Fungibility::Fungible as XcmFungible,108 MultiAsset,109 Error as XcmError,110};111use xcm_executor::traits::{MatchesFungible, WeightTrader};112//use xcm_executor::traits::MatchesFungible;113use sp_runtime::traits::CheckedConversion;114115use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};116117pub const RUNTIME_NAME: &str = "Opal";118119type CrossAccountId = frame_common::account::BasicCrossAccountId<Runtime>;120121impl RuntimeInstance for Runtime {122 type CrossAccountId = self::CrossAccountId;123 type TransactionConverter = self::TransactionConverter;124125 fn get_transaction_converter() -> TransactionConverter {126 TransactionConverter127 }128}129130/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know131/// the specifics of the runtime. They can then be made to be agnostic over specific formats132/// of data like extrinsics, allowing for them to continue syncing the network through upgrades133/// to even the core data structures.134pub mod opaque {135 use sp_std::prelude::*;136 use sp_runtime::impl_opaque_keys;137 use super::Aura;138139 pub use unique_runtime_common::types::*;140141 impl_opaque_keys! {142 pub struct SessionKeys {143 pub aura: Aura,144 }145 }146}147148/// This runtime version.149pub const VERSION: RuntimeVersion = RuntimeVersion {150 spec_name: create_runtime_str!(RUNTIME_NAME),151 impl_name: create_runtime_str!(RUNTIME_NAME),152 authoring_version: 1,153 spec_version: 917004,154 impl_version: 0,155 apis: RUNTIME_API_VERSIONS,156 transaction_version: 1,157 state_version: 0,158};159160#[derive(codec::Encode, codec::Decode)]161pub enum XCMPMessage<XAccountId, XBalance> {162 /// Transfer tokens to the given account from the Parachain account.163 TransferToken(XAccountId, XBalance),164}165166/// The version information used to identify this runtime when compiled natively.167#[cfg(feature = "std")]168pub fn native_version() -> NativeVersion {169 NativeVersion {170 runtime_version: VERSION,171 can_author_with: Default::default(),172 }173}174175type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;176177pub struct DealWithFees;178impl OnUnbalanced<NegativeImbalance> for DealWithFees {179 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {180 if let Some(fees) = fees_then_tips.next() {181 // for fees, 100% to treasury182 let mut split = fees.ration(100, 0);183 if let Some(tips) = fees_then_tips.next() {184 // for tips, if any, 100% to treasury185 tips.ration_merge_into(100, 0, &mut split);186 }187 Treasury::on_unbalanced(split.0);188 // Author::on_unbalanced(split.1);189 }190 }191}192193parameter_types! {194 pub const BlockHashCount: BlockNumber = 2400;195 pub RuntimeBlockLength: BlockLength =196 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);197 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);198 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;199 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()200 .base_block(BlockExecutionWeight::get())201 .for_class(DispatchClass::all(), |weights| {202 weights.base_extrinsic = ExtrinsicBaseWeight::get();203 })204 .for_class(DispatchClass::Normal, |weights| {205 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);206 })207 .for_class(DispatchClass::Operational, |weights| {208 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);209 // Operational transactions have some extra reserved space, so that they210 // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.211 weights.reserved = Some(212 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT213 );214 })215 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)216 .build_or_panic();217 pub const Version: RuntimeVersion = VERSION;218 pub const SS58Prefix: u8 = 42;219}220221parameter_types! {222 pub const ChainId: u64 = 8882;223}224225pub struct FixedFee;226impl FeeCalculator for FixedFee {227 fn min_gas_price() -> U256 {228 MIN_GAS_PRICE.into()229 }230}231232// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case233// (contract, which only writes a lot of data),234// approximating on top of our real store write weight235parameter_types! {236 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;237 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;238 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();239}240241/// Limiting EVM execution to 50% of block for substrate users and management tasks242/// EVM transaction consumes more weight than substrate's, so we can't rely on them being243/// scheduled fairly244const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);245parameter_types! {246 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());247}248249pub enum FixedGasWeightMapping {}250impl GasWeightMapping for FixedGasWeightMapping {251 fn gas_to_weight(gas: u64) -> Weight {252 gas.saturating_mul(WeightPerGas::get())253 }254 fn weight_to_gas(weight: Weight) -> u64 {255 weight / WeightPerGas::get()256 }257}258259impl pallet_evm::Config for Runtime {260 type BlockGasLimit = BlockGasLimit;261 type FeeCalculator = FixedFee;262 type GasWeightMapping = FixedGasWeightMapping;263 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;264 type CallOrigin = EnsureAddressTruncated;265 type WithdrawOrigin = EnsureAddressTruncated;266 type AddressMapping = HashedAddressMapping<Self::Hashing>;267 type PrecompilesType = ();268 type PrecompilesValue = ();269 type Currency = Balances;270 type Event = Event;271 type OnMethodCall = (272 pallet_evm_migration::OnMethodCall<Self>,273 pallet_unique::UniqueErcSupport<Self>,274 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,275 );276 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;277 type ChainId = ChainId;278 type Runner = pallet_evm::runner::stack::Runner<Self>;279 type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;280 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;281 type FindAuthor = EthereumFindAuthor<Aura>;282}283284impl pallet_evm_migration::Config for Runtime {285 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;286}287288impl frame_common::account::Config for Runtime {289 type EvmAddressMapping = pallet_evm::HashedAddressMapping<Self::Hashing>;290 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;291}292293pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);294impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {295 fn find_author<'a, I>(digests: I) -> Option<H160>296 where297 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,298 {299 if let Some(author_index) = F::find_author(digests) {300 let authority_id = Aura::authorities()[author_index as usize].clone();301 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));302 }303 None304 }305}306307impl pallet_ethereum::Config for Runtime {308 type Event = Event;309 type StateRoot = pallet_ethereum::IntermediateStateRoot;310}311312impl pallet_randomness_collective_flip::Config for Runtime {}313314impl frame_system::Config for Runtime {315 /// The data to be stored in an account.316 type AccountData = pallet_balances::AccountData<Balance>;317 /// The identifier used to distinguish between accounts.318 type AccountId = AccountId;319 /// The basic call filter to use in dispatchable.320 type BaseCallFilter = Everything;321 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).322 type BlockHashCount = BlockHashCount;323 /// The maximum length of a block (in bytes).324 type BlockLength = RuntimeBlockLength;325 /// The index type for blocks.326 type BlockNumber = BlockNumber;327 /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.328 type BlockWeights = RuntimeBlockWeights;329 /// The aggregated dispatch type that is available for extrinsics.330 type Call = Call;331 /// The weight of database operations that the runtime can invoke.332 type DbWeight = RocksDbWeight;333 /// The ubiquitous event type.334 type Event = Event;335 /// The type for hashing blocks and tries.336 type Hash = Hash;337 /// The hashing algorithm used.338 type Hashing = BlakeTwo256;339 /// The header type.340 type Header = generic::Header<BlockNumber, BlakeTwo256>;341 /// The index type for storing how many extrinsics an account has signed.342 type Index = Index;343 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.344 type Lookup = AccountIdLookup<AccountId, ()>;345 /// What to do if an account is fully reaped from the system.346 type OnKilledAccount = ();347 /// What to do if a new account is created.348 type OnNewAccount = ();349 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;350 /// The ubiquitous origin type.351 type Origin = Origin;352 /// This type is being generated by `construct_runtime!`.353 type PalletInfo = PalletInfo;354 /// This is used as an identifier of the chain. 42 is the generic substrate prefix.355 type SS58Prefix = SS58Prefix;356 /// Weight information for the extrinsics of this pallet.357 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;358 /// Version of the runtime.359 type Version = Version;360 type MaxConsumers = ConstU32<16>;361}362363parameter_types! {364 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;365}366367impl pallet_timestamp::Config for Runtime {368 /// A timestamp: milliseconds since the unix epoch.369 type Moment = u64;370 type OnTimestampSet = ();371 type MinimumPeriod = MinimumPeriod;372 type WeightInfo = ();373}374375parameter_types! {376 // pub const ExistentialDeposit: u128 = 500;377 pub const ExistentialDeposit: u128 = 0;378 pub const MaxLocks: u32 = 50;379}380381impl pallet_balances::Config for Runtime {382 type MaxLocks = MaxLocks;383 type MaxReserves = ();384 type ReserveIdentifier = [u8; 8];385 /// The type for recording an account's balance.386 type Balance = Balance;387 /// The ubiquitous event type.388 type Event = Event;389 type DustRemoval = Treasury;390 type ExistentialDeposit = ExistentialDeposit;391 type AccountStore = System;392 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;393}394395pub const fn deposit(items: u32, bytes: u32) -> Balance {396 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE397}398399/*400parameter_types! {401 pub TombstoneDeposit: Balance = deposit(402 1,403 sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,404 );405 pub DepositPerContract: Balance = TombstoneDeposit::get();406 pub const DepositPerStorageByte: Balance = deposit(0, 1);407 pub const DepositPerStorageItem: Balance = deposit(1, 0);408 pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);409 pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;410 pub const SignedClaimHandicap: u32 = 2;411 pub const MaxDepth: u32 = 32;412 pub const MaxValueSize: u32 = 16 * 1024;413 pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb414 // The lazy deletion runs inside on_initialize.415 pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *416 RuntimeBlockWeights::get().max_block;417 // The weight needed for decoding the queue should be less or equal than a fifth418 // of the overall weight dedicated to the lazy deletion.419 pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (420 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -421 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)422 )) / 5) as u32;423 pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();424}425426impl pallet_contracts::Config for Runtime {427 type Time = Timestamp;428 type Randomness = RandomnessCollectiveFlip;429 type Currency = Balances;430 type Event = Event;431 type RentPayment = ();432 type SignedClaimHandicap = SignedClaimHandicap;433 type TombstoneDeposit = TombstoneDeposit;434 type DepositPerContract = DepositPerContract;435 type DepositPerStorageByte = DepositPerStorageByte;436 type DepositPerStorageItem = DepositPerStorageItem;437 type RentFraction = RentFraction;438 type SurchargeReward = SurchargeReward;439 type WeightPrice = pallet_transaction_payment::Pallet<Self>;440 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;441 type ChainExtension = NFTExtension;442 type DeletionQueueDepth = DeletionQueueDepth;443 type DeletionWeightLimit = DeletionWeightLimit;444 type Schedule = Schedule;445 type CallStack = [pallet_contracts::Frame<Self>; 31];446}447*/448449parameter_types! {450 /// This value increases the priority of `Operational` transactions by adding451 /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.452 pub const OperationalFeeMultiplier: u8 = 5;453}454455/// Linear implementor of `WeightToFeePolynomial`456pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);457458impl<T> WeightToFeePolynomial for LinearFee<T>459where460 T: BaseArithmetic + From<u32> + Copy + Unsigned,461{462 type Balance = T;463464 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {465 smallvec!(WeightToFeeCoefficient {466 // Targeting 0.1 Unique per NFT transfer467 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),468 coeff_frac: Perbill::zero(),469 negative: false,470 degree: 1,471 })472 }473}474475impl pallet_transaction_payment::Config for Runtime {476 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;477 type TransactionByteFee = TransactionByteFee;478 type OperationalFeeMultiplier = OperationalFeeMultiplier;479 type WeightToFee = LinearFee<Balance>;480 type FeeMultiplierUpdate = ();481}482483parameter_types! {484 pub const ProposalBond: Permill = Permill::from_percent(5);485 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;486 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;487 pub const SpendPeriod: BlockNumber = 5 * MINUTES;488 pub const Burn: Permill = Permill::from_percent(0);489 pub const TipCountdown: BlockNumber = 1 * DAYS;490 pub const TipFindersFee: Percent = Percent::from_percent(20);491 pub const TipReportDepositBase: Balance = 1 * UNIQUE;492 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;493 pub const BountyDepositBase: Balance = 1 * UNIQUE;494 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;495 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");496 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;497 pub const MaximumReasonLength: u32 = 16384;498 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);499 pub const BountyValueMinimum: Balance = 5 * UNIQUE;500 pub const MaxApprovals: u32 = 100;501}502503impl pallet_treasury::Config for Runtime {504 type PalletId = TreasuryModuleId;505 type Currency = Balances;506 type ApproveOrigin = EnsureRoot<AccountId>;507 type RejectOrigin = EnsureRoot<AccountId>;508 type Event = Event;509 type OnSlash = ();510 type ProposalBond = ProposalBond;511 type ProposalBondMinimum = ProposalBondMinimum;512 type ProposalBondMaximum = ProposalBondMaximum;513 type SpendPeriod = SpendPeriod;514 type Burn = Burn;515 type BurnDestination = ();516 type SpendFunds = ();517 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;518 type MaxApprovals = MaxApprovals;519}520521impl pallet_sudo::Config for Runtime {522 type Event = Event;523 type Call = Call;524}525526pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);527528impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider529 for RelayChainBlockNumberProvider<T>530{531 type BlockNumber = BlockNumber;532533 fn current_block_number() -> Self::BlockNumber {534 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()535 .map(|d| d.relay_parent_number)536 .unwrap_or_default()537 }538}539540parameter_types! {541 pub const MinVestedTransfer: Balance = 10 * UNIQUE;542 pub const MaxVestingSchedules: u32 = 28;543}544545impl orml_vesting::Config for Runtime {546 type Event = Event;547 type Currency = pallet_balances::Pallet<Runtime>;548 type MinVestedTransfer = MinVestedTransfer;549 type VestedTransferOrigin = EnsureSigned<AccountId>;550 type WeightInfo = ();551 type MaxVestingSchedules = MaxVestingSchedules;552 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;553}554555parameter_types! {556 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;557 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;558}559560impl cumulus_pallet_parachain_system::Config for Runtime {561 type Event = Event;562 type SelfParaId = parachain_info::Pallet<Self>;563 type OnSystemEvent = ();564 // type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<565 // MaxDownwardMessageWeight,566 // XcmExecutor<XcmConfig>,567 // Call,568 // >;569 type OutboundXcmpMessageSource = XcmpQueue;570 type DmpMessageHandler = DmpQueue;571 type ReservedDmpWeight = ReservedDmpWeight;572 type ReservedXcmpWeight = ReservedXcmpWeight;573 type XcmpMessageHandler = XcmpQueue;574}575576impl parachain_info::Config for Runtime {}577578impl cumulus_pallet_aura_ext::Config for Runtime {}579580parameter_types! {581 pub const RelayLocation: MultiLocation = MultiLocation::parent();582 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;583 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();584 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();585}586587/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used588/// when determining ownership of accounts for asset transacting and when attempting to use XCM589/// `Transact` in order to determine the dispatch Origin.590pub type LocationToAccountId = (591 // The parent (Relay-chain) origin converts to the default `AccountId`.592 ParentIsPreset<AccountId>,593 // Sibling parachain origins convert to AccountId via the `ParaId::into`.594 SiblingParachainConvertsVia<Sibling, AccountId>,595 // Straight up local `AccountId32` origins just alias directly to `AccountId`.596 AccountId32Aliases<RelayNetwork, AccountId>,597);598599pub struct OnlySelfCurrency;600impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {601 fn matches_fungible(a: &MultiAsset) -> Option<B> {602 match (&a.id, &a.fun) {603 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),604 _ => None,605 }606 }607}608609/// Means for transacting assets on this chain.610pub type LocalAssetTransactor = CurrencyAdapter<611 // Use this currency:612 Balances,613 // Use this currency when it is a fungible asset matching the given location or name:614 OnlySelfCurrency,615 // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:616 LocationToAccountId,617 // Our chain's account ID type (we can't get away without mentioning it explicitly):618 AccountId,619 // We don't track any teleports.620 (),621>;622623/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,624/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can625/// biases the kind of local `Origin` it will become.626pub type XcmOriginToTransactDispatchOrigin = (627 // Sovereign account converter; this attempts to derive an `AccountId` from the origin location628 // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for629 // foreign chains who want to have a local sovereign account on this chain which they control.630 SovereignSignedViaLocation<LocationToAccountId, Origin>,631 // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when632 // recognised.633 RelayChainAsNative<RelayOrigin, Origin>,634 // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when635 // recognised.636 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,637 // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a638 // transaction from the Root origin.639 ParentAsSuperuser<Origin>,640 // Native signed account converter; this just converts an `AccountId32` origin into a normal641 // `Origin::Signed` origin of the same 32-byte value.642 SignedAccountId32AsNative<RelayNetwork, Origin>,643 // Xcm origins can be represented natively under the Xcm pallet's Xcm origin.644 XcmPassthrough<Origin>,645);646647parameter_types! {648 // One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.649 pub UnitWeightCost: Weight = 1_000_000;650 // 1200 UNIQUEs buy 1 second of weight.651 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);652 pub const MaxInstructions: u32 = 100;653 pub const MaxAuthorities: u32 = 100_000;654}655656match_type! {657 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {658 MultiLocation { parents: 1, interior: Here } |659 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }660 };661}662663pub type Barrier = (664 TakeWeightCredit,665 AllowTopLevelPaidExecutionFrom<Everything>,666 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,667 // ^^^ Parent & its unit plurality gets free execution668);669670pub struct UsingOnlySelfCurrencyComponents<671 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,672 AssetId: Get<MultiLocation>,673 AccountId,674 Currency: CurrencyT<AccountId>,675 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,676>(677 Weight,678 Currency::Balance,679 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,680);681impl<682 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,683 AssetId: Get<MultiLocation>,684 AccountId,685 Currency: CurrencyT<AccountId>,686 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,687 > WeightTrader688 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>689{690 fn new() -> Self {691 Self(0, Zero::zero(), PhantomData)692 }693694 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {695 let amount = WeightToFee::calc(&weight);696 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;697698 // location to this parachain through relay chain699 let option1: xcm::v1::AssetId = Concrete(MultiLocation {700 parents: 1,701 interior: X1(Parachain(ParachainInfo::parachain_id().into())),702 });703 // direct location704 let option2: xcm::v1::AssetId = Concrete(MultiLocation {705 parents: 0,706 interior: Here,707 });708709 let required = if payment.fungible.contains_key(&option1) {710 (option1, u128_amount).into()711 } else if payment.fungible.contains_key(&option2) {712 (option2, u128_amount).into()713 } else {714 (Concrete(MultiLocation::default()), u128_amount).into()715 };716717 let unused = payment718 .checked_sub(required)719 .map_err(|_| XcmError::TooExpensive)?;720 self.0 = self.0.saturating_add(weight);721 self.1 = self.1.saturating_add(amount);722 Ok(unused)723 }724725 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {726 let weight = weight.min(self.0);727 let amount = WeightToFee::calc(&weight);728 self.0 -= weight;729 self.1 = self.1.saturating_sub(amount);730 let amount: u128 = amount.saturated_into();731 if amount > 0 {732 Some((AssetId::get(), amount).into())733 } else {734 None735 }736 }737}738impl<739 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,740 AssetId: Get<MultiLocation>,741 AccountId,742 Currency: CurrencyT<AccountId>,743 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,744 > Drop745 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>746{747 fn drop(&mut self) {748 OnUnbalanced::on_unbalanced(Currency::issue(self.1));749 }750}751752pub struct XcmConfig;753impl Config for XcmConfig {754 type Call = Call;755 type XcmSender = XcmRouter;756 // How to withdraw and deposit an asset.757 type AssetTransactor = LocalAssetTransactor;758 type OriginConverter = XcmOriginToTransactDispatchOrigin;759 type IsReserve = NativeAsset;760 type IsTeleporter = (); // Teleportation is disabled761 type LocationInverter = LocationInverter<Ancestry>;762 type Barrier = Barrier;763 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;764 type Trader = UsingOnlySelfCurrencyComponents<765 IdentityFee<Balance>,766 RelayLocation,767 AccountId,768 Balances,769 (),770 >;771 type ResponseHandler = (); // Don't handle responses for now.772 type SubscriptionService = PolkadotXcm;773774 type AssetTrap = PolkadotXcm;775 type AssetClaims = PolkadotXcm;776}777778// parameter_types! {779// pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;780// }781782/// No local origins on this chain are allowed to dispatch XCM sends/executions.783pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);784785/// The means for routing XCM messages which are not for local execution into the right message786/// queues.787pub type XcmRouter = (788 // Two routers - use UMP to communicate with the relay chain:789 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,790 // ..and XCMP to communicate with the sibling chains.791 XcmpQueue,792);793794impl pallet_evm_coder_substrate::Config for Runtime {795 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;796 type GasWeightMapping = FixedGasWeightMapping;797}798799impl pallet_xcm::Config for Runtime {800 type Event = Event;801 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;802 type XcmRouter = XcmRouter;803 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;804 type XcmExecuteFilter = Everything;805 type XcmExecutor = XcmExecutor<XcmConfig>;806 type XcmTeleportFilter = Everything;807 type XcmReserveTransferFilter = Everything;808 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;809 type LocationInverter = LocationInverter<Ancestry>;810 type Origin = Origin;811 type Call = Call;812 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;813 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;814}815816impl cumulus_pallet_xcm::Config for Runtime {817 type Event = Event;818 type XcmExecutor = XcmExecutor<XcmConfig>;819}820821impl cumulus_pallet_xcmp_queue::Config for Runtime {822 type WeightInfo = ();823 type Event = Event;824 type XcmExecutor = XcmExecutor<XcmConfig>;825 type ChannelInfo = ParachainSystem;826 type VersionWrapper = ();827 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;828 type ControllerOrigin = EnsureRoot<AccountId>;829 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;830}831832impl cumulus_pallet_dmp_queue::Config for Runtime {833 type Event = Event;834 type XcmExecutor = XcmExecutor<XcmConfig>;835 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;836}837838impl pallet_aura::Config for Runtime {839 type AuthorityId = AuraId;840 type DisabledValidators = ();841 type MaxAuthorities = MaxAuthorities;842}843844parameter_types! {845 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();846 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;847}848849impl pallet_common::Config for Runtime {850 type Event = Event;851 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;852 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;853 type CrossAccountId = frame_common::account::BasicCrossAccountId<Self>;854855 type Currency = Balances;856 type CollectionCreationPrice = CollectionCreationPrice;857 type TreasuryAccountId = TreasuryAccountId;858}859860impl pallet_fungible::Config for Runtime {861 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;862}863impl pallet_refungible::Config for Runtime {864 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;865}866impl pallet_nonfungible::Config for Runtime {867 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;868}869870impl pallet_unique::Config for Runtime {871 type Event = Event;872 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;873}874875parameter_types! {876 pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied877}878879/// Used for the pallet inflation880impl pallet_inflation::Config for Runtime {881 type Currency = Balances;882 type TreasuryAccountId = TreasuryAccountId;883 type InflationBlockInterval = InflationBlockInterval;884 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;885}886887// parameter_types! {888// pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *889// RuntimeBlockWeights::get().max_block;890// pub const MaxScheduledPerBlock: u32 = 50;891// }892893type EvmSponsorshipHandler = (894 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,895 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,896);897type SponsorshipHandler = (898 pallet_unique::UniqueSponsorshipHandler<Runtime>,899 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,900 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,901);902903// impl pallet_unq_scheduler::Config for Runtime {904// type Event = Event;905// type Origin = Origin;906// type PalletsOrigin = OriginCaller;907// type Call = Call;908// type MaximumWeight = MaximumSchedulerWeight;909// type ScheduleOrigin = EnsureSigned<AccountId>;910// type MaxScheduledPerBlock = MaxScheduledPerBlock;911// type SponsorshipHandler = SponsorshipHandler;912// type WeightInfo = ();913// }914915impl pallet_evm_transaction_payment::Config for Runtime {916 type EvmSponsorshipHandler = EvmSponsorshipHandler;917 type Currency = Balances;918 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;919 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;920}921922impl pallet_charge_transaction::Config for Runtime {923 type SponsorshipHandler = SponsorshipHandler;924}925926// impl pallet_contract_helpers::Config for Runtime {927// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;928// }929930parameter_types! {931 // 0x842899ECF380553E8a4de75bF534cdf6fBF64049932 pub const HelpersContractAddress: H160 = H160([933 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,934 ]);935}936937impl pallet_evm_contract_helpers::Config for Runtime {938 type ContractAddress = HelpersContractAddress;939 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;940 type EvmAddressMapping = pallet_evm::HashedAddressMapping<Self::Hashing>;941 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;942}943944construct_runtime!(945 pub enum Runtime where946 Block = Block,947 NodeBlock = opaque::Block,948 UncheckedExtrinsic = UncheckedExtrinsic949 {950 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,951 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,952953 Aura: pallet_aura::{Pallet, Config<T>} = 22,954 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,955956 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,957 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,958 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,959 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,960 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,961 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,962 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,963 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,964 // Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,965 // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,966967 // XCM helpers.968 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,969 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,970 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,971 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,972973 // Unique Pallets974 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,975 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,976 // Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,977 // free = 63978 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,979 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,980 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,981 Fungible: pallet_fungible::{Pallet, Storage} = 67,982 Refungible: pallet_refungible::{Pallet, Storage} = 68,983 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,984985 // Frontier986 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,987 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,988989 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,990 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,991 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,992 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,993 }994);995996pub struct TransactionConverter;997998impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {999 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1000 UncheckedExtrinsic::new_unsigned(1001 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1002 )1003 }1004}10051006impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1007 fn convert_transaction(1008 &self,1009 transaction: pallet_ethereum::Transaction,1010 ) -> opaque::UncheckedExtrinsic {1011 let extrinsic = UncheckedExtrinsic::new_unsigned(1012 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1013 );1014 let encoded = extrinsic.encode();1015 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1016 .expect("Encoded extrinsic is always valid")1017 }1018}10191020/// The address format for describing accounts.1021pub type Address = sp_runtime::MultiAddress<AccountId, ()>;1022/// Block header type as expected by this runtime.1023pub type Header = generic::Header<BlockNumber, BlakeTwo256>;1024/// Block type as expected by this runtime.1025pub type Block = generic::Block<Header, UncheckedExtrinsic>;1026/// A Block signed with a Justification1027pub type SignedBlock = generic::SignedBlock<Block>;1028/// BlockId type as expected by this runtime.1029pub type BlockId = generic::BlockId<Block>;1030/// The SignedExtension to the basic transaction logic.1031pub type SignedExtra = (1032 frame_system::CheckSpecVersion<Runtime>,1033 // system::CheckTxVersion<Runtime>,1034 frame_system::CheckGenesis<Runtime>,1035 frame_system::CheckEra<Runtime>,1036 frame_system::CheckNonce<Runtime>,1037 frame_system::CheckWeight<Runtime>,1038 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1039 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,1040);1041/// Unchecked extrinsic type as expected by this runtime.1042pub type UncheckedExtrinsic =1043 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;1044/// Extrinsic type that has already been checked.1045pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;1046/// Executive: handles dispatch to the various modules.1047pub type Executive = frame_executive::Executive<1048 Runtime,1049 Block,1050 frame_system::ChainContext<Runtime>,1051 Runtime,1052 AllPalletsReversedWithSystemFirst,1053>;10541055impl_opaque_keys! {1056 pub struct SessionKeys {1057 pub aura: Aura,1058 }1059}10601061impl fp_self_contained::SelfContainedCall for Call {1062 type SignedInfo = H160;10631064 fn is_self_contained(&self) -> bool {1065 match self {1066 Call::Ethereum(call) => call.is_self_contained(),1067 _ => false,1068 }1069 }10701071 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1072 match self {1073 Call::Ethereum(call) => call.check_self_contained(),1074 _ => None,1075 }1076 }10771078 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1079 match self {1080 Call::Ethereum(call) => call.validate_self_contained(info),1081 _ => None,1082 }1083 }10841085 fn pre_dispatch_self_contained(1086 &self,1087 info: &Self::SignedInfo,1088 ) -> Option<Result<(), TransactionValidityError>> {1089 match self {1090 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1091 _ => None,1092 }1093 }10941095 fn apply_self_contained(1096 self,1097 info: Self::SignedInfo,1098 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1099 match self {1100 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1101 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1102 )),1103 _ => None,1104 }1105 }1106}11071108macro_rules! dispatch_unique_runtime {1109 ($collection:ident.$method:ident($($name:ident),*)) => {{1110 use pallet_unique::dispatch::Dispatched;11111112 let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1113 let dispatch = collection.as_dyn();11141115 Ok(dispatch.$method($($name),*))1116 }};1117}11181119impl_common_runtime_apis!();11201121struct CheckInherents;11221123impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1124 fn check_inherents(1125 block: &Block,1126 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1127 ) -> sp_inherents::CheckInherentsResult {1128 let relay_chain_slot = relay_state_proof1129 .read_slot()1130 .expect("Could not read the relay chain slot from the proof");11311132 let inherent_data =1133 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1134 relay_chain_slot,1135 sp_std::time::Duration::from_secs(6),1136 )1137 .create_inherent_data()1138 .expect("Could not create the timestamp inherent data");11391140 inherent_data.check_extrinsics(block)1141 }1142}11431144cumulus_pallet_parachain_system::register_validate_block!(1145 Runtime = Runtime,1146 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1147 CheckInherents = CheckInherents,1148);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::{EnsureAddressTruncated, HashedAddressMapping, Runner};52pub use frame_support::{53 construct_runtime, match_type,54 dispatch::DispatchResult,55 PalletId, parameter_types, StorageValue, ConsensusEngineId,56 traits::{57 tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,58 Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,59 OnUnbalanced, Randomness, FindAuthor,60 },61 weights::{62 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},63 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,64 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,65 },66};67use up_data_structs::*;68// use pallet_contracts::weights::WeightInfo;69// #[cfg(any(feature = "std", test))]70use frame_system::{71 self as frame_system, EnsureRoot, EnsureSigned,72 limits::{BlockWeights, BlockLength},73};74use sp_arithmetic::{75 traits::{BaseArithmetic, Unsigned},76};77use smallvec::smallvec;78use codec::{Encode, Decode};79use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping, OnMethodCall};80use fp_rpc::TransactionStatus;81use sp_runtime::{82 traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},83 transaction_validity::TransactionValidityError,84 SaturatedConversion,85};8687// pub use pallet_timestamp::Call as TimestampCall;88pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;8990// Polkadot imports91use pallet_xcm::XcmPassthrough;92use polkadot_parachain::primitives::Sibling;93use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};94use xcm_builder::{95 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,96 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,97 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,98 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,99 ParentIsPreset,100};101use xcm_executor::{Config, XcmExecutor, Assets};102use sp_std::{marker::PhantomData};103104use xcm::latest::{105 // Xcm,106 AssetId::{Concrete},107 Fungibility::Fungible as XcmFungible,108 MultiAsset,109 Error as XcmError,110};111use xcm_executor::traits::{MatchesFungible, WeightTrader};112//use xcm_executor::traits::MatchesFungible;113use sp_runtime::traits::CheckedConversion;114115use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};116117pub const RUNTIME_NAME: &str = "Opal";118119type CrossAccountId = frame_common::account::BasicCrossAccountId<Runtime>;120121impl RuntimeInstance for Runtime {122 type CrossAccountId = self::CrossAccountId;123 type TransactionConverter = self::TransactionConverter;124125 fn get_transaction_converter() -> TransactionConverter {126 TransactionConverter127 }128}129130/// The type for looking up accounts. We don't expect more than 4 billion of them, but you131/// never know...132pub type AccountIndex = u32;133134/// Balance of an account.135pub type Balance = u128;136137/// Index of a transaction in the chain.138pub type Index = u32;139140/// A hash of some data used by the chain.141pub type Hash = sp_core::H256;142143/// Digest item type.144pub type DigestItem = generic::DigestItem;145146/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know147/// the specifics of the runtime. They can then be made to be agnostic over specific formats148/// of data like extrinsics, allowing for them to continue syncing the network through upgrades149/// to even the core data structures.150pub mod opaque {151 use sp_std::prelude::*;152 use sp_runtime::impl_opaque_keys;153 use super::Aura;154155 pub use unique_runtime_common::types::*;156157 impl_opaque_keys! {158 pub struct SessionKeys {159 pub aura: Aura,160 }161 }162}163164/// This runtime version.165pub const VERSION: RuntimeVersion = RuntimeVersion {166 spec_name: create_runtime_str!(RUNTIME_NAME),167 impl_name: create_runtime_str!(RUNTIME_NAME),168 authoring_version: 1,169 spec_version: 917004,170 impl_version: 0,171 apis: RUNTIME_API_VERSIONS,172 transaction_version: 1,173 state_version: 0,174};175176#[derive(codec::Encode, codec::Decode)]177pub enum XCMPMessage<XAccountId, XBalance> {178 /// Transfer tokens to the given account from the Parachain account.179 TransferToken(XAccountId, XBalance),180}181182/// The version information used to identify this runtime when compiled natively.183#[cfg(feature = "std")]184pub fn native_version() -> NativeVersion {185 NativeVersion {186 runtime_version: VERSION,187 can_author_with: Default::default(),188 }189}190191type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;192193pub struct DealWithFees;194impl OnUnbalanced<NegativeImbalance> for DealWithFees {195 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {196 if let Some(fees) = fees_then_tips.next() {197 // for fees, 100% to treasury198 let mut split = fees.ration(100, 0);199 if let Some(tips) = fees_then_tips.next() {200 // for tips, if any, 100% to treasury201 tips.ration_merge_into(100, 0, &mut split);202 }203 Treasury::on_unbalanced(split.0);204 // Author::on_unbalanced(split.1);205 }206 }207}208209parameter_types! {210 pub const BlockHashCount: BlockNumber = 2400;211 pub RuntimeBlockLength: BlockLength =212 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);213 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);214 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;215 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()216 .base_block(BlockExecutionWeight::get())217 .for_class(DispatchClass::all(), |weights| {218 weights.base_extrinsic = ExtrinsicBaseWeight::get();219 })220 .for_class(DispatchClass::Normal, |weights| {221 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);222 })223 .for_class(DispatchClass::Operational, |weights| {224 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);225 // Operational transactions have some extra reserved space, so that they226 // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.227 weights.reserved = Some(228 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT229 );230 })231 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)232 .build_or_panic();233 pub const Version: RuntimeVersion = VERSION;234 pub const SS58Prefix: u8 = 42;235}236237parameter_types! {238 pub const ChainId: u64 = 8882;239}240241pub struct FixedFee;242impl FeeCalculator for FixedFee {243 fn min_gas_price() -> U256 {244 MIN_GAS_PRICE.into()245 }246}247248// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case249// (contract, which only writes a lot of data),250// approximating on top of our real store write weight251parameter_types! {252 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;253 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;254 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();255}256257/// Limiting EVM execution to 50% of block for substrate users and management tasks258/// EVM transaction consumes more weight than substrate's, so we can't rely on them being259/// scheduled fairly260const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);261parameter_types! {262 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());263}264265pub enum FixedGasWeightMapping {}266impl GasWeightMapping for FixedGasWeightMapping {267 fn gas_to_weight(gas: u64) -> Weight {268 gas.saturating_mul(WeightPerGas::get())269 }270 fn weight_to_gas(weight: Weight) -> u64 {271 weight / WeightPerGas::get()272 }273}274275impl pallet_evm::account::Config for Runtime {276 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;277 type EvmAddressMapping = pallet_evm::HashedAddressMapping<Self::Hashing>;278 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;279}280281impl pallet_evm::Config for Runtime {282 type BlockGasLimit = BlockGasLimit;283 type FeeCalculator = FixedFee;284 type GasWeightMapping = FixedGasWeightMapping;285 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;286 type CallOrigin = EnsureAddressTruncated;287 type WithdrawOrigin = EnsureAddressTruncated;288 type AddressMapping = HashedAddressMapping<Self::Hashing>;289 type PrecompilesType = ();290 type PrecompilesValue = ();291 type Currency = Balances;292 type Event = Event;293 type OnMethodCall = (294 pallet_evm_migration::OnMethodCall<Self>,295 pallet_unique::UniqueErcSupport<Self>,296 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,297 );298 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;299 type ChainId = ChainId;300 type Runner = pallet_evm::runner::stack::Runner<Self>;301 type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;302 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;303 type FindAuthor = EthereumFindAuthor<Aura>;304}305306impl pallet_evm_migration::Config for Runtime {307 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;308}309310pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);311impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {312 fn find_author<'a, I>(digests: I) -> Option<H160>313 where314 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,315 {316 if let Some(author_index) = F::find_author(digests) {317 let authority_id = Aura::authorities()[author_index as usize].clone();318 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));319 }320 None321 }322}323324impl pallet_ethereum::Config for Runtime {325 type Event = Event;326 type StateRoot = pallet_ethereum::IntermediateStateRoot;327}328329impl pallet_randomness_collective_flip::Config for Runtime {}330331impl frame_system::Config for Runtime {332 /// The data to be stored in an account.333 type AccountData = pallet_balances::AccountData<Balance>;334 /// The identifier used to distinguish between accounts.335 type AccountId = AccountId;336 /// The basic call filter to use in dispatchable.337 type BaseCallFilter = Everything;338 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).339 type BlockHashCount = BlockHashCount;340 /// The maximum length of a block (in bytes).341 type BlockLength = RuntimeBlockLength;342 /// The index type for blocks.343 type BlockNumber = BlockNumber;344 /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.345 type BlockWeights = RuntimeBlockWeights;346 /// The aggregated dispatch type that is available for extrinsics.347 type Call = Call;348 /// The weight of database operations that the runtime can invoke.349 type DbWeight = RocksDbWeight;350 /// The ubiquitous event type.351 type Event = Event;352 /// The type for hashing blocks and tries.353 type Hash = Hash;354 /// The hashing algorithm used.355 type Hashing = BlakeTwo256;356 /// The header type.357 type Header = generic::Header<BlockNumber, BlakeTwo256>;358 /// The index type for storing how many extrinsics an account has signed.359 type Index = Index;360 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.361 type Lookup = AccountIdLookup<AccountId, ()>;362 /// What to do if an account is fully reaped from the system.363 type OnKilledAccount = ();364 /// What to do if a new account is created.365 type OnNewAccount = ();366 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;367 /// The ubiquitous origin type.368 type Origin = Origin;369 /// This type is being generated by `construct_runtime!`.370 type PalletInfo = PalletInfo;371 /// This is used as an identifier of the chain. 42 is the generic substrate prefix.372 type SS58Prefix = SS58Prefix;373 /// Weight information for the extrinsics of this pallet.374 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;375 /// Version of the runtime.376 type Version = Version;377 type MaxConsumers = ConstU32<16>;378}379380parameter_types! {381 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;382}383384impl pallet_timestamp::Config for Runtime {385 /// A timestamp: milliseconds since the unix epoch.386 type Moment = u64;387 type OnTimestampSet = ();388 type MinimumPeriod = MinimumPeriod;389 type WeightInfo = ();390}391392parameter_types! {393 // pub const ExistentialDeposit: u128 = 500;394 pub const ExistentialDeposit: u128 = 0;395 pub const MaxLocks: u32 = 50;396}397398impl pallet_balances::Config for Runtime {399 type MaxLocks = MaxLocks;400 type MaxReserves = ();401 type ReserveIdentifier = [u8; 8];402 /// The type for recording an account's balance.403 type Balance = Balance;404 /// The ubiquitous event type.405 type Event = Event;406 type DustRemoval = Treasury;407 type ExistentialDeposit = ExistentialDeposit;408 type AccountStore = System;409 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;410}411412pub const fn deposit(items: u32, bytes: u32) -> Balance {413 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE414}415416/*417parameter_types! {418 pub TombstoneDeposit: Balance = deposit(419 1,420 sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,421 );422 pub DepositPerContract: Balance = TombstoneDeposit::get();423 pub const DepositPerStorageByte: Balance = deposit(0, 1);424 pub const DepositPerStorageItem: Balance = deposit(1, 0);425 pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);426 pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;427 pub const SignedClaimHandicap: u32 = 2;428 pub const MaxDepth: u32 = 32;429 pub const MaxValueSize: u32 = 16 * 1024;430 pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb431 // The lazy deletion runs inside on_initialize.432 pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *433 RuntimeBlockWeights::get().max_block;434 // The weight needed for decoding the queue should be less or equal than a fifth435 // of the overall weight dedicated to the lazy deletion.436 pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (437 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -438 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)439 )) / 5) as u32;440 pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();441}442443impl pallet_contracts::Config for Runtime {444 type Time = Timestamp;445 type Randomness = RandomnessCollectiveFlip;446 type Currency = Balances;447 type Event = Event;448 type RentPayment = ();449 type SignedClaimHandicap = SignedClaimHandicap;450 type TombstoneDeposit = TombstoneDeposit;451 type DepositPerContract = DepositPerContract;452 type DepositPerStorageByte = DepositPerStorageByte;453 type DepositPerStorageItem = DepositPerStorageItem;454 type RentFraction = RentFraction;455 type SurchargeReward = SurchargeReward;456 type WeightPrice = pallet_transaction_payment::Pallet<Self>;457 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;458 type ChainExtension = NFTExtension;459 type DeletionQueueDepth = DeletionQueueDepth;460 type DeletionWeightLimit = DeletionWeightLimit;461 type Schedule = Schedule;462 type CallStack = [pallet_contracts::Frame<Self>; 31];463}464*/465466parameter_types! {467 /// This value increases the priority of `Operational` transactions by adding468 /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.469 pub const OperationalFeeMultiplier: u8 = 5;470}471472/// Linear implementor of `WeightToFeePolynomial`473pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);474475impl<T> WeightToFeePolynomial for LinearFee<T>476where477 T: BaseArithmetic + From<u32> + Copy + Unsigned,478{479 type Balance = T;480481 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {482 smallvec!(WeightToFeeCoefficient {483 // Targeting 0.1 Unique per NFT transfer484 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),485 coeff_frac: Perbill::zero(),486 negative: false,487 degree: 1,488 })489 }490}491492impl pallet_transaction_payment::Config for Runtime {493 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;494 type TransactionByteFee = TransactionByteFee;495 type OperationalFeeMultiplier = OperationalFeeMultiplier;496 type WeightToFee = LinearFee<Balance>;497 type FeeMultiplierUpdate = ();498}499500parameter_types! {501 pub const ProposalBond: Permill = Permill::from_percent(5);502 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;503 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;504 pub const SpendPeriod: BlockNumber = 5 * MINUTES;505 pub const Burn: Permill = Permill::from_percent(0);506 pub const TipCountdown: BlockNumber = 1 * DAYS;507 pub const TipFindersFee: Percent = Percent::from_percent(20);508 pub const TipReportDepositBase: Balance = 1 * UNIQUE;509 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;510 pub const BountyDepositBase: Balance = 1 * UNIQUE;511 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;512 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");513 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;514 pub const MaximumReasonLength: u32 = 16384;515 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);516 pub const BountyValueMinimum: Balance = 5 * UNIQUE;517 pub const MaxApprovals: u32 = 100;518}519520impl pallet_treasury::Config for Runtime {521 type PalletId = TreasuryModuleId;522 type Currency = Balances;523 type ApproveOrigin = EnsureRoot<AccountId>;524 type RejectOrigin = EnsureRoot<AccountId>;525 type Event = Event;526 type OnSlash = ();527 type ProposalBond = ProposalBond;528 type ProposalBondMinimum = ProposalBondMinimum;529 type ProposalBondMaximum = ProposalBondMaximum;530 type SpendPeriod = SpendPeriod;531 type Burn = Burn;532 type BurnDestination = ();533 type SpendFunds = ();534 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;535 type MaxApprovals = MaxApprovals;536}537538impl pallet_sudo::Config for Runtime {539 type Event = Event;540 type Call = Call;541}542543pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);544545impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider546 for RelayChainBlockNumberProvider<T>547{548 type BlockNumber = BlockNumber;549550 fn current_block_number() -> Self::BlockNumber {551 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()552 .map(|d| d.relay_parent_number)553 .unwrap_or_default()554 }555}556557parameter_types! {558 pub const MinVestedTransfer: Balance = 10 * UNIQUE;559 pub const MaxVestingSchedules: u32 = 28;560}561562impl orml_vesting::Config for Runtime {563 type Event = Event;564 type Currency = pallet_balances::Pallet<Runtime>;565 type MinVestedTransfer = MinVestedTransfer;566 type VestedTransferOrigin = EnsureSigned<AccountId>;567 type WeightInfo = ();568 type MaxVestingSchedules = MaxVestingSchedules;569 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;570}571572parameter_types! {573 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;574 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;575}576577impl cumulus_pallet_parachain_system::Config for Runtime {578 type Event = Event;579 type SelfParaId = parachain_info::Pallet<Self>;580 type OnSystemEvent = ();581 // type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<582 // MaxDownwardMessageWeight,583 // XcmExecutor<XcmConfig>,584 // Call,585 // >;586 type OutboundXcmpMessageSource = XcmpQueue;587 type DmpMessageHandler = DmpQueue;588 type ReservedDmpWeight = ReservedDmpWeight;589 type ReservedXcmpWeight = ReservedXcmpWeight;590 type XcmpMessageHandler = XcmpQueue;591}592593impl parachain_info::Config for Runtime {}594595impl cumulus_pallet_aura_ext::Config for Runtime {}596597parameter_types! {598 pub const RelayLocation: MultiLocation = MultiLocation::parent();599 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;600 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();601 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();602}603604/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used605/// when determining ownership of accounts for asset transacting and when attempting to use XCM606/// `Transact` in order to determine the dispatch Origin.607pub type LocationToAccountId = (608 // The parent (Relay-chain) origin converts to the default `AccountId`.609 ParentIsPreset<AccountId>,610 // Sibling parachain origins convert to AccountId via the `ParaId::into`.611 SiblingParachainConvertsVia<Sibling, AccountId>,612 // Straight up local `AccountId32` origins just alias directly to `AccountId`.613 AccountId32Aliases<RelayNetwork, AccountId>,614);615616pub struct OnlySelfCurrency;617impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {618 fn matches_fungible(a: &MultiAsset) -> Option<B> {619 match (&a.id, &a.fun) {620 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),621 _ => None,622 }623 }624}625626/// Means for transacting assets on this chain.627pub type LocalAssetTransactor = CurrencyAdapter<628 // Use this currency:629 Balances,630 // Use this currency when it is a fungible asset matching the given location or name:631 OnlySelfCurrency,632 // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:633 LocationToAccountId,634 // Our chain's account ID type (we can't get away without mentioning it explicitly):635 AccountId,636 // We don't track any teleports.637 (),638>;639640/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,641/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can642/// biases the kind of local `Origin` it will become.643pub type XcmOriginToTransactDispatchOrigin = (644 // Sovereign account converter; this attempts to derive an `AccountId` from the origin location645 // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for646 // foreign chains who want to have a local sovereign account on this chain which they control.647 SovereignSignedViaLocation<LocationToAccountId, Origin>,648 // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when649 // recognised.650 RelayChainAsNative<RelayOrigin, Origin>,651 // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when652 // recognised.653 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,654 // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a655 // transaction from the Root origin.656 ParentAsSuperuser<Origin>,657 // Native signed account converter; this just converts an `AccountId32` origin into a normal658 // `Origin::Signed` origin of the same 32-byte value.659 SignedAccountId32AsNative<RelayNetwork, Origin>,660 // Xcm origins can be represented natively under the Xcm pallet's Xcm origin.661 XcmPassthrough<Origin>,662);663664parameter_types! {665 // One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.666 pub UnitWeightCost: Weight = 1_000_000;667 // 1200 UNIQUEs buy 1 second of weight.668 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);669 pub const MaxInstructions: u32 = 100;670 pub const MaxAuthorities: u32 = 100_000;671}672673match_type! {674 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {675 MultiLocation { parents: 1, interior: Here } |676 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }677 };678}679680pub type Barrier = (681 TakeWeightCredit,682 AllowTopLevelPaidExecutionFrom<Everything>,683 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,684 // ^^^ Parent & its unit plurality gets free execution685);686687pub struct UsingOnlySelfCurrencyComponents<688 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,689 AssetId: Get<MultiLocation>,690 AccountId,691 Currency: CurrencyT<AccountId>,692 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,693>(694 Weight,695 Currency::Balance,696 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,697);698impl<699 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,700 AssetId: Get<MultiLocation>,701 AccountId,702 Currency: CurrencyT<AccountId>,703 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,704 > WeightTrader705 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>706{707 fn new() -> Self {708 Self(0, Zero::zero(), PhantomData)709 }710711 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {712 let amount = WeightToFee::calc(&weight);713 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;714715 // location to this parachain through relay chain716 let option1: xcm::v1::AssetId = Concrete(MultiLocation {717 parents: 1,718 interior: X1(Parachain(ParachainInfo::parachain_id().into())),719 });720 // direct location721 let option2: xcm::v1::AssetId = Concrete(MultiLocation {722 parents: 0,723 interior: Here,724 });725726 let required = if payment.fungible.contains_key(&option1) {727 (option1, u128_amount).into()728 } else if payment.fungible.contains_key(&option2) {729 (option2, u128_amount).into()730 } else {731 (Concrete(MultiLocation::default()), u128_amount).into()732 };733734 let unused = payment735 .checked_sub(required)736 .map_err(|_| XcmError::TooExpensive)?;737 self.0 = self.0.saturating_add(weight);738 self.1 = self.1.saturating_add(amount);739 Ok(unused)740 }741742 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {743 let weight = weight.min(self.0);744 let amount = WeightToFee::calc(&weight);745 self.0 -= weight;746 self.1 = self.1.saturating_sub(amount);747 let amount: u128 = amount.saturated_into();748 if amount > 0 {749 Some((AssetId::get(), amount).into())750 } else {751 None752 }753 }754}755impl<756 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,757 AssetId: Get<MultiLocation>,758 AccountId,759 Currency: CurrencyT<AccountId>,760 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,761 > Drop762 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>763{764 fn drop(&mut self) {765 OnUnbalanced::on_unbalanced(Currency::issue(self.1));766 }767}768769pub struct XcmConfig;770impl Config for XcmConfig {771 type Call = Call;772 type XcmSender = XcmRouter;773 // How to withdraw and deposit an asset.774 type AssetTransactor = LocalAssetTransactor;775 type OriginConverter = XcmOriginToTransactDispatchOrigin;776 type IsReserve = NativeAsset;777 type IsTeleporter = (); // Teleportation is disabled778 type LocationInverter = LocationInverter<Ancestry>;779 type Barrier = Barrier;780 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;781 type Trader = UsingOnlySelfCurrencyComponents<782 IdentityFee<Balance>,783 RelayLocation,784 AccountId,785 Balances,786 (),787 >;788 type ResponseHandler = (); // Don't handle responses for now.789 type SubscriptionService = PolkadotXcm;790791 type AssetTrap = PolkadotXcm;792 type AssetClaims = PolkadotXcm;793}794795// parameter_types! {796// pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;797// }798799/// No local origins on this chain are allowed to dispatch XCM sends/executions.800pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);801802/// The means for routing XCM messages which are not for local execution into the right message803/// queues.804pub type XcmRouter = (805 // Two routers - use UMP to communicate with the relay chain:806 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,807 // ..and XCMP to communicate with the sibling chains.808 XcmpQueue,809);810811impl pallet_evm_coder_substrate::Config for Runtime {812 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;813 type GasWeightMapping = FixedGasWeightMapping;814}815816impl pallet_xcm::Config for Runtime {817 type Event = Event;818 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;819 type XcmRouter = XcmRouter;820 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;821 type XcmExecuteFilter = Everything;822 type XcmExecutor = XcmExecutor<XcmConfig>;823 type XcmTeleportFilter = Everything;824 type XcmReserveTransferFilter = Everything;825 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;826 type LocationInverter = LocationInverter<Ancestry>;827 type Origin = Origin;828 type Call = Call;829 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;830 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;831}832833impl cumulus_pallet_xcm::Config for Runtime {834 type Event = Event;835 type XcmExecutor = XcmExecutor<XcmConfig>;836}837838impl cumulus_pallet_xcmp_queue::Config for Runtime {839 type WeightInfo = ();840 type Event = Event;841 type XcmExecutor = XcmExecutor<XcmConfig>;842 type ChannelInfo = ParachainSystem;843 type VersionWrapper = ();844 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;845 type ControllerOrigin = EnsureRoot<AccountId>;846 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;847}848849impl cumulus_pallet_dmp_queue::Config for Runtime {850 type Event = Event;851 type XcmExecutor = XcmExecutor<XcmConfig>;852 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;853}854855impl pallet_aura::Config for Runtime {856 type AuthorityId = AuraId;857 type DisabledValidators = ();858 type MaxAuthorities = MaxAuthorities;859}860861parameter_types! {862 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();863 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;864}865866impl pallet_common::Config for Runtime {867 type Event = Event;868 type Currency = Balances;869 type CollectionCreationPrice = CollectionCreationPrice;870 type TreasuryAccountId = TreasuryAccountId;871}872873impl pallet_fungible::Config for Runtime {874 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;875}876impl pallet_refungible::Config for Runtime {877 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;878}879impl pallet_nonfungible::Config for Runtime {880 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;881}882883impl pallet_unique::Config for Runtime {884 type Event = Event;885 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;886}887888parameter_types! {889 pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied890}891892/// Used for the pallet inflation893impl pallet_inflation::Config for Runtime {894 type Currency = Balances;895 type TreasuryAccountId = TreasuryAccountId;896 type InflationBlockInterval = InflationBlockInterval;897 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;898}899900// parameter_types! {901// pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *902// RuntimeBlockWeights::get().max_block;903// pub const MaxScheduledPerBlock: u32 = 50;904// }905906type EvmSponsorshipHandler = (907 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,908 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,909);910type SponsorshipHandler = (911 pallet_unique::UniqueSponsorshipHandler<Runtime>,912 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,913 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,914);915916// impl pallet_unq_scheduler::Config for Runtime {917// type Event = Event;918// type Origin = Origin;919// type PalletsOrigin = OriginCaller;920// type Call = Call;921// type MaximumWeight = MaximumSchedulerWeight;922// type ScheduleOrigin = EnsureSigned<AccountId>;923// type MaxScheduledPerBlock = MaxScheduledPerBlock;924// type SponsorshipHandler = SponsorshipHandler;925// type WeightInfo = ();926// }927928impl pallet_evm_transaction_payment::Config for Runtime {929 type EvmSponsorshipHandler = EvmSponsorshipHandler;930 type Currency = Balances;931}932933impl pallet_charge_transaction::Config for Runtime {934 type SponsorshipHandler = SponsorshipHandler;935}936937// impl pallet_contract_helpers::Config for Runtime {938// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;939// }940941parameter_types! {942 // 0x842899ECF380553E8a4de75bF534cdf6fBF64049943 pub const HelpersContractAddress: H160 = H160([944 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,945 ]);946}947948impl pallet_evm_contract_helpers::Config for Runtime {949 type ContractAddress = HelpersContractAddress;950 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;951 type EvmAddressMapping = pallet_evm::HashedAddressMapping<Self::Hashing>;952 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;953}954955construct_runtime!(956 pub enum Runtime where957 Block = Block,958 NodeBlock = opaque::Block,959 UncheckedExtrinsic = UncheckedExtrinsic960 {961 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,962 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,963964 Aura: pallet_aura::{Pallet, Config<T>} = 22,965 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,966967 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,968 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,969 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,970 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,971 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,972 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,973 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,974 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,975 // Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,976 // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,977978 // XCM helpers.979 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,980 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,981 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,982 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,983984 // Unique Pallets985 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,986 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,987 // Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,988 // free = 63989 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,990 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,991 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,992 Fungible: pallet_fungible::{Pallet, Storage} = 67,993 Refungible: pallet_refungible::{Pallet, Storage} = 68,994 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,995996 // Frontier997 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,998 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,9991000 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1001 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1002 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1003 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1004 }1005);10061007pub struct TransactionConverter;10081009impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1010 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1011 UncheckedExtrinsic::new_unsigned(1012 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1013 )1014 }1015}10161017impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1018 fn convert_transaction(1019 &self,1020 transaction: pallet_ethereum::Transaction,1021 ) -> opaque::UncheckedExtrinsic {1022 let extrinsic = UncheckedExtrinsic::new_unsigned(1023 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1024 );1025 let encoded = extrinsic.encode();1026 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1027 .expect("Encoded extrinsic is always valid")1028 }1029}10301031/// The address format for describing accounts.1032pub type Address = sp_runtime::MultiAddress<AccountId, ()>;1033/// Block header type as expected by this runtime.1034pub type Header = generic::Header<BlockNumber, BlakeTwo256>;1035/// Block type as expected by this runtime.1036pub type Block = generic::Block<Header, UncheckedExtrinsic>;1037/// A Block signed with a Justification1038pub type SignedBlock = generic::SignedBlock<Block>;1039/// BlockId type as expected by this runtime.1040pub type BlockId = generic::BlockId<Block>;1041/// The SignedExtension to the basic transaction logic.1042pub type SignedExtra = (1043 frame_system::CheckSpecVersion<Runtime>,1044 // system::CheckTxVersion<Runtime>,1045 frame_system::CheckGenesis<Runtime>,1046 frame_system::CheckEra<Runtime>,1047 frame_system::CheckNonce<Runtime>,1048 frame_system::CheckWeight<Runtime>,1049 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1050 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,1051);1052/// Unchecked extrinsic type as expected by this runtime.1053pub type UncheckedExtrinsic =1054 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;1055/// Extrinsic type that has already been checked.1056pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;1057/// Executive: handles dispatch to the various modules.1058pub type Executive = frame_executive::Executive<1059 Runtime,1060 Block,1061 frame_system::ChainContext<Runtime>,1062 Runtime,1063 AllPalletsReversedWithSystemFirst,1064>;10651066impl_opaque_keys! {1067 pub struct SessionKeys {1068 pub aura: Aura,1069 }1070}10711072impl fp_self_contained::SelfContainedCall for Call {1073 type SignedInfo = H160;10741075 fn is_self_contained(&self) -> bool {1076 match self {1077 Call::Ethereum(call) => call.is_self_contained(),1078 _ => false,1079 }1080 }10811082 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1083 match self {1084 Call::Ethereum(call) => call.check_self_contained(),1085 _ => None,1086 }1087 }10881089 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1090 match self {1091 Call::Ethereum(call) => call.validate_self_contained(info),1092 _ => None,1093 }1094 }10951096 fn pre_dispatch_self_contained(1097 &self,1098 info: &Self::SignedInfo,1099 ) -> Option<Result<(), TransactionValidityError>> {1100 match self {1101 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1102 _ => None,1103 }1104 }11051106 fn apply_self_contained(1107 self,1108 info: Self::SignedInfo,1109 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1110 match self {1111 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1112 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1113 )),1114 _ => None,1115 }1116 }1117}11181119macro_rules! dispatch_unique_runtime {1120 ($collection:ident.$method:ident($($name:ident),*)) => {{1121 use pallet_unique::dispatch::Dispatched;11221123 let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1124 let dispatch = collection.as_dyn();11251126 Ok(dispatch.$method($($name),*))1127 }};1128}11291130impl_common_runtime_apis!();11311132struct CheckInherents;11331134impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1135 fn check_inherents(1136 block: &Block,1137 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1138 ) -> sp_inherents::CheckInherentsResult {1139 let relay_chain_slot = relay_state_proof1140 .read_slot()1141 .expect("Could not read the relay chain slot from the proof");11421143 let inherent_data =1144 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1145 relay_chain_slot,1146 sp_std::time::Duration::from_secs(6),1147 )1148 .create_inherent_data()1149 .expect("Could not create the timestamp inherent data");11501151 inherent_data.check_extrinsics(block)1152 }1153}11541155cumulus_pallet_parachain_system::register_validate_block!(1156 Runtime = Runtime,1157 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1158 CheckInherents = CheckInherents,1159);