git.delta.rocks / unique-network / refs/commits / 7ca598f7f6b8

difftreelog

fix use ChainSpecBuilder

Daniel Shiposha2024-05-27parent: #078678e.patch.diff
in: master

8 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6380,6 +6380,7 @@
  "sp-block-builder",
  "sp-consensus-aura",
  "sp-core",
+ "sp-genesis-builder",
  "sp-inherents",
  "sp-io",
  "sp-offchain",
@@ -10261,6 +10262,7 @@
  "sp-block-builder",
  "sp-consensus-aura",
  "sp-core",
+ "sp-genesis-builder",
  "sp-inherents",
  "sp-io",
  "sp-offchain",
@@ -15134,6 +15136,7 @@
  "sp-block-builder",
  "sp-consensus-aura",
  "sp-core",
+ "sp-genesis-builder",
  "sp-inherents",
  "sp-io",
  "sp-offchain",
modifiedCargo.tomldiffbeforeafterboth
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -181,6 +181,7 @@
 sp-trie = { default-features = false, version = "32.0.0" }
 sp-version = { default-features = false, version = "32.0.0" }
 sp-weights = { default-features = false, version = "30.0.0" }
+sp-genesis-builder = { default-features = false, version = "0.10.0" }
 staging-parachain-info = { default-features = false, version = "0.10.0" }
 staging-xcm = { default-features = false, version = "10.0.0" }
 staging-xcm-builder = { default-features = false, version = "10.0.0" }
@@ -217,4 +218,5 @@
 log = { version = "0.4.20", default-features = false }
 num_enum = { version = "0.7.0", default-features = false }
 serde = { default-features = false, features = ['derive'], version = "1.0.188" }
+serde_json = "1"
 smallvec = "1.11.1"
modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -14,8 +14,6 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-use std::collections::BTreeMap;
-
 use default_runtime::WASM_BINARY;
 #[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]
 pub use opal_runtime as default_runtime;
@@ -24,7 +22,7 @@
 use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
 use sc_service::ChainType;
 use serde::{Deserialize, Serialize};
-use serde_json::map::Map;
+use serde_json::{json, map::Map};
 use sp_core::{sr25519, Pair, Public};
 use sp_runtime::traits::{IdentifyAccount, Verify};
 #[cfg(feature = "unique-runtime")]
@@ -142,184 +140,102 @@
 	AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
 }
 
-#[cfg(not(feature = "unique-runtime"))]
-macro_rules! testnet_genesis {
-	(
-		$runtime:path,
-		$root_key:expr,
-		$initial_invulnerables:expr,
-		$endowed_accounts:expr,
-		$id:expr
-	) => {{
-		use $runtime::*;
-
-		RuntimeGenesisConfig {
-			system: Default::default(),
-			balances: BalancesConfig {
-				balances: $endowed_accounts
-					.iter()
-					.cloned()
-					// 1e13 UNQ
-					.map(|k| (k, 1 << 100))
-					.collect(),
-			},
-			sudo: SudoConfig {
-				key: Some($root_key),
-			},
-
-			vesting: VestingConfig { vesting: vec![] },
-			parachain_info: ParachainInfoConfig {
-				parachain_id: $id.into(),
-				..Default::default()
-			},
-			collator_selection: CollatorSelectionConfig {
-				invulnerables: $initial_invulnerables
-					.iter()
-					.cloned()
-					.map(|(acc, _)| acc)
-					.collect(),
-			},
-			session: SessionConfig {
-				keys: $initial_invulnerables
-					.into_iter()
-					.map(|(acc, aura)| {
-						(
-							acc.clone(),          // account id
-							acc,                  // validator id
-							SessionKeys { aura }, // session keys
-						)
-					})
-					.collect(),
-			},
-			evm: EVMConfig {
-				accounts: BTreeMap::new(),
-				..Default::default()
-			},
-			..Default::default()
+pub fn test_config(chain_id: &str, relay_chain: &str) -> DefaultChainSpec {
+	DefaultChainSpec::builder(
+		WASM_BINARY.expect("WASM binary was not build, please build it!"),
+		Extensions {
+			relay_chain: relay_chain.into(),
+			para_id: PARA_ID,
+		},
+	)
+	.with_id(&format!(
+		"{}_{}",
+		default_runtime::VERSION.spec_name,
+		chain_id
+	))
+	.with_name(&format!(
+		"{}{}",
+		default_runtime::VERSION.spec_name.to_uppercase(),
+		if cfg!(feature = "unique-runtime") {
+			""
+		} else {
+			" by UNIQUE"
 		}
-	}};
+	))
+	.with_properties(chain_properties())
+	.with_chain_type(ChainType::Development)
+	.with_genesis_config_patch(genesis_patch())
+	.build()
 }
 
-#[cfg(feature = "unique-runtime")]
-macro_rules! testnet_genesis {
-	(
-		$runtime:path,
-		$root_key:expr,
-		$initial_invulnerables:expr,
-		$endowed_accounts:expr,
-		$id:expr
-	) => {{
-		use $runtime::*;
+fn genesis_patch() -> serde_json::Value {
+	use default_runtime::*;
 
-		RuntimeGenesisConfig {
-			system: Default::default(),
-			balances: BalancesConfig {
-				balances: $endowed_accounts
-					.iter()
-					.cloned()
-					// 1e13 UNQ
-					.map(|k| (k, 1 << 100))
-					.collect(),
-			},
-			sudo: SudoConfig {
-				key: Some($root_key),
-			},
-			vesting: VestingConfig { vesting: vec![] },
-			parachain_info: ParachainInfoConfig {
-				parachain_id: $id.into(),
-				..Default::default()
-			},
-			aura: AuraConfig {
-				authorities: $initial_invulnerables
-					.into_iter()
-					.map(|(_, aura)| aura)
-					.collect(),
-			},
-			evm: EVMConfig {
-				accounts: BTreeMap::new(),
-				..Default::default()
-			},
-			..Default::default()
-		}
-	}};
-}
+	let invulnerables = ["Alice", "Bob"];
 
-pub fn development_config() -> DefaultChainSpec {
-	let mut properties = Map::new();
-	properties.insert("tokenSymbol".into(), default_runtime::TOKEN_SYMBOL.into());
-	properties.insert("tokenDecimals".into(), default_runtime::DECIMALS.into());
-	properties.insert(
-		"ss58Format".into(),
-		default_runtime::SS58Prefix::get().into(),
-	);
+	#[allow(unused_mut)]
+	let mut patch = json!({
+		"parachainInfo": {
+			"parachainId": PARA_ID,
+		},
 
-	DefaultChainSpec::from_genesis(
-		// Name
-		format!(
-			"{}{}",
-			default_runtime::VERSION.spec_name.to_uppercase(),
-			if cfg!(feature = "unique-runtime") {
-				""
-			} else {
-				" by UNIQUE"
-			}
-		)
-		.as_str(),
-		// ID
-		format!("{}_dev", default_runtime::VERSION.spec_name).as_str(),
-		ChainType::Local,
-		move || {
-			testnet_genesis!(
-				default_runtime,
-				// Sudo account
-				get_account_id_from_seed::<sr25519::Public>("Alice"),
-				[
+		"aura": {
+			"authorities": invulnerables.into_iter()
+				.map(|name| get_from_seed::<AuraId>(name))
+				.collect::<Vec<_>>(),
+		},
+
+		"session": {
+			"keys": invulnerables.into_iter()
+				.map(|name| {
+					let account = get_account_id_from_seed::<sr25519::Public>(name);
+					let aura = get_from_seed::<AuraId>(name);
+
 					(
-						get_account_id_from_seed::<sr25519::Public>("Alice"),
-						get_from_seed::<AuraId>("Alice"),
-					),
-					(
-						get_account_id_from_seed::<sr25519::Public>("Bob"),
-						get_from_seed::<AuraId>("Bob"),
-					),
-				],
-				// Pre-funded accounts
-				vec![
-					get_account_id_from_seed::<sr25519::Public>("Alice"),
-					get_account_id_from_seed::<sr25519::Public>("Bob"),
-					get_account_id_from_seed::<sr25519::Public>("Charlie"),
-					get_account_id_from_seed::<sr25519::Public>("Dave"),
-					get_account_id_from_seed::<sr25519::Public>("Eve"),
-					get_account_id_from_seed::<sr25519::Public>("Ferdie"),
-					get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
-					get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
-					get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
-					get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
-					get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
-					get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
-				],
-				PARA_ID
-			)
+						/*   account id: */ account.clone(),
+						/* validator id: */ account,
+						/* session keys: */ SessionKeys { aura },
+					)
+				})
+				.collect::<Vec<_>>()
+		},
+
+		"sudo": {
+			"key": get_account_id_from_seed::<sr25519::Public>("Alice"),
 		},
-		// Bootnodes
-		vec![],
-		// Telemetry
-		None,
-		// Protocol ID
-		None,
-		None,
-		// Properties
-		Some(properties),
-		// Extensions
-		Extensions {
-			relay_chain: "rococo-dev".into(),
-			para_id: PARA_ID,
+
+		"balances": {
+			"balances": &[
+				get_account_id_from_seed::<sr25519::Public>("Alice"),
+				get_account_id_from_seed::<sr25519::Public>("Bob"),
+				get_account_id_from_seed::<sr25519::Public>("Charlie"),
+				get_account_id_from_seed::<sr25519::Public>("Dave"),
+				get_account_id_from_seed::<sr25519::Public>("Eve"),
+				get_account_id_from_seed::<sr25519::Public>("Ferdie"),
+				get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
+				get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
+				get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
+				get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
+				get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
+				get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
+			].into_iter()
+			.map(|k| (k, /* ~1.2e+12 UNQ */ 1u128 << 100))
+			.collect::<Vec<_>>(),
 		},
-		WASM_BINARY.expect("WASM binary was not build, please build it!"),
-	)
+	});
+
+	#[cfg(feature = "unique-runtime")]
+	{
+		patch
+			.as_object_mut()
+			.expect("the genesis patch is always an object; qed")
+			.remove("session");
+	}
+
+	patch
 }
 
-pub fn local_testnet_config() -> DefaultChainSpec {
+fn chain_properties() -> sc_chain_spec::Properties {
 	let mut properties = Map::new();
 	properties.insert("tokenSymbol".into(), default_runtime::TOKEN_SYMBOL.into());
 	properties.insert("tokenDecimals".into(), default_runtime::DECIMALS.into());
@@ -328,68 +244,5 @@
 		default_runtime::SS58Prefix::get().into(),
 	);
 
-	DefaultChainSpec::from_genesis(
-		// Name
-		format!(
-			"{}{}",
-			default_runtime::VERSION.impl_name.to_uppercase(),
-			if cfg!(feature = "unique-runtime") {
-				""
-			} else {
-				" by UNIQUE"
-			}
-		)
-		.as_str(),
-		// ID
-		format!("{}_local", default_runtime::VERSION.spec_name).as_str(),
-		ChainType::Local,
-		move || {
-			testnet_genesis!(
-				default_runtime,
-				// Sudo account
-				get_account_id_from_seed::<sr25519::Public>("Alice"),
-				[
-					(
-						get_account_id_from_seed::<sr25519::Public>("Alice"),
-						get_from_seed::<AuraId>("Alice"),
-					),
-					(
-						get_account_id_from_seed::<sr25519::Public>("Bob"),
-						get_from_seed::<AuraId>("Bob"),
-					),
-				],
-				// Pre-funded accounts
-				vec![
-					get_account_id_from_seed::<sr25519::Public>("Alice"),
-					get_account_id_from_seed::<sr25519::Public>("Bob"),
-					get_account_id_from_seed::<sr25519::Public>("Charlie"),
-					get_account_id_from_seed::<sr25519::Public>("Dave"),
-					get_account_id_from_seed::<sr25519::Public>("Eve"),
-					get_account_id_from_seed::<sr25519::Public>("Ferdie"),
-					get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
-					get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
-					get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
-					get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
-					get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
-					get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
-				],
-				PARA_ID
-			)
-		},
-		// Bootnodes
-		vec![],
-		// Telemetry
-		None,
-		// Protocol ID
-		None,
-		None,
-		// Properties
-		Some(properties),
-		// Extensions
-		Extensions {
-			relay_chain: "westend-local".into(),
-			para_id: PARA_ID,
-		},
-		WASM_BINARY.expect("WASM binary was not build, please build it!"),
-	)
+	properties
 }
modifiednode/cli/src/command.rsdiffbeforeafterboth
--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -49,9 +49,7 @@
 use crate::{
 	chain_spec::{self, RuntimeIdentification, ServiceId, ServiceIdentification},
 	cli::{Cli, RelayChainCli, Subcommand},
-	service::{
-		new_partial, start_dev_node, start_node, OpalRuntimeExecutor, ParachainHostFunctions,
-	},
+	service::{new_partial, start_dev_node, start_node, OpalRuntimeExecutor},
 };
 
 macro_rules! no_runtime_err {
@@ -65,8 +63,8 @@
 
 fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
 	Ok(match id {
-		"dev" => Box::new(chain_spec::development_config()),
-		"" | "local" => Box::new(chain_spec::local_testnet_config()),
+		"dev" => Box::new(chain_spec::test_config("dev", "rococo-dev")),
+		"" | "local" => Box::new(chain_spec::test_config("local", "westend-local")),
 		path => {
 			let path = std::path::PathBuf::from(path);
 			#[allow(clippy::redundant_clone)]
@@ -352,6 +350,8 @@
 			use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
 			use polkadot_cli::Block;
 
+			use crate::service::ParachainHostFunctions;
+
 			type Header = <Block as sp_runtime::traits::Block>::Header;
 			type Hasher = <Header as sp_runtime::traits::Header>::Hashing;
 
@@ -403,7 +403,7 @@
 			use std::{future::Future, pin::Pin};
 
 			use polkadot_cli::Block;
-			use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
+			use sc_executor::NativeExecutionDispatch;
 			use try_runtime_cli::block_building_info::timestamp_with_aura_info;
 
 			let runner = cli.create_runner(cmd)?;
modifiedruntime/common/runtime_apis.rsdiffbeforeafterboth
before · runtime/common/runtime_apis.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#[macro_export]18macro_rules! dispatch_unique_runtime {19	($collection:ident.$method:ident($($name:ident),*) $($rest:tt)*) => {{20		let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch($collection)?;21		let dispatch = collection.as_dyn();2223		Ok::<_, DispatchError>(dispatch.$method($($name),*) $($rest)*)24	}};25}2627#[macro_export]28macro_rules! impl_common_runtime_apis {29	(30		$(31			#![custom_apis]3233			$($custom_apis:tt)+34		)?35	) => {36		use sp_std::prelude::*;37		use sp_api::impl_runtime_apis;38		use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};39		use sp_runtime::{40			Permill,41			traits::{Block as BlockT},42			transaction_validity::{TransactionSource, TransactionValidity},43			ApplyExtrinsicResult, DispatchError, ExtrinsicInclusionMode,44		};45		use frame_support::{46			pallet_prelude::Weight,47			traits::OnFinalize,48		};49		use fp_rpc::TransactionStatus;50		use pallet_transaction_payment::{51			FeeDetails, RuntimeDispatchInfo,52		};53		use pallet_evm::{54			Runner, account::CrossAccountId as _,55			Account as EVMAccount, FeeCalculator,56		};57		use runtime_common::{58			sponsoring::{SponsorshipPredict, UniqueSponsorshipPredict},59			dispatch::CollectionDispatch,60			config::ethereum::CrossAccountId,61		};62		use up_data_structs::*;6364		impl_runtime_apis! {65			$($($custom_apis)+)?6667			impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId> for Runtime {68				fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {69					dispatch_unique_runtime!(collection.account_tokens(account))70				}71				fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>, DispatchError> {72					dispatch_unique_runtime!(collection.collection_tokens())73				}74				fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {75					dispatch_unique_runtime!(collection.token_exists(token))76				}7778				fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {79					dispatch_unique_runtime!(collection.token_owner(token).ok())80				}8182				fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec::<CrossAccountId>, DispatchError>  {83					dispatch_unique_runtime!(collection.token_owners(token))84				}8586				fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {87					let budget = budget::Value::new(10);8889					<pallet_structure::Pallet<Runtime>>::find_topmost_owner(collection, token, &budget)90				}91				fn token_children(collection: CollectionId, token: TokenId) -> Result<Vec<TokenChild>, DispatchError> {92					Ok(<pallet_nonfungible::Pallet<Runtime>>::token_children_ids(collection, token))93				}94				fn collection_properties(95					collection: CollectionId,96					keys: Option<Vec<Vec<u8>>>97				) -> Result<Vec<Property>, DispatchError> {98					let keys = keys.map(99						|keys| Common::bytes_keys_to_property_keys(keys)100					).transpose()?;101102					Common::filter_collection_properties(collection, keys)103				}104105				fn token_properties(106					collection: CollectionId,107					token_id: TokenId,108					keys: Option<Vec<Vec<u8>>>109				) -> Result<Vec<Property>, DispatchError> {110					let keys = keys.map(111						|keys| Common::bytes_keys_to_property_keys(keys)112					).transpose()?;113114					dispatch_unique_runtime!(collection.token_properties(token_id, keys))115				}116117				fn property_permissions(118					collection: CollectionId,119					keys: Option<Vec<Vec<u8>>>120				) -> Result<Vec<PropertyKeyPermission>, DispatchError> {121					let keys = keys.map(122						|keys| Common::bytes_keys_to_property_keys(keys)123					).transpose()?;124125					Common::filter_property_permissions(collection, keys)126				}127128				fn token_data(129					collection: CollectionId,130					token_id: TokenId,131					keys: Option<Vec<Vec<u8>>>132				) -> Result<TokenData<CrossAccountId>, DispatchError> {133					let token_data = TokenData {134						properties: Self::token_properties(collection, token_id, keys)?,135						owner: Self::token_owner(collection, token_id)?,136						pieces: Self::total_pieces(collection, token_id)?.unwrap_or(0),137					};138139					Ok(token_data)140				}141142				fn total_supply(collection: CollectionId) -> Result<u32, DispatchError> {143					dispatch_unique_runtime!(collection.total_supply())144				}145				fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {146					dispatch_unique_runtime!(collection.account_balance(account))147				}148				fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {149					dispatch_unique_runtime!(collection.balance(account, token))150				}151				fn allowance(152					collection: CollectionId,153					sender: CrossAccountId,154					spender: CrossAccountId,155					token: TokenId,156				) -> Result<u128, DispatchError> {157					dispatch_unique_runtime!(collection.allowance(sender, spender, token))158				}159160				fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {161					Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))162				}163				fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {164					Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))165				}166				fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {167					Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))168				}169				fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {170					dispatch_unique_runtime!(collection.last_token_id())171				}172				fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>, DispatchError> {173					Ok(<pallet_common::Pallet<Runtime>>::rpc_collection(collection))174				}175				fn collection_stats() -> Result<CollectionStats, DispatchError> {176					Ok(<pallet_common::Pallet<Runtime>>::collection_stats())177				}178				fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>, DispatchError> {179					Ok(<UniqueSponsorshipPredict<Runtime> as SponsorshipPredict<Runtime>>::predict(180						collection,181						account,182						token183					))184				}185186				fn effective_collection_limits(collection: CollectionId) -> Result<Option<CollectionLimits>, DispatchError> {187					Ok(<pallet_common::Pallet<Runtime>>::effective_collection_limits(collection))188				}189190				fn total_pieces(collection: CollectionId, token_id: TokenId) -> Result<Option<u128>, DispatchError> {191					dispatch_unique_runtime!(collection.total_pieces(token_id))192				}193194				fn allowance_for_all(collection: CollectionId, owner: CrossAccountId, operator: CrossAccountId) -> Result<bool, DispatchError> {195					dispatch_unique_runtime!(collection.allowance_for_all(owner, operator))196				}197			}198199			impl app_promotion_rpc::AppPromotionApi<Block, BlockNumber, CrossAccountId, AccountId> for Runtime {200				#[allow(unused_variables)]201				fn total_staked(staker: Option<CrossAccountId>) -> Result<u128, DispatchError> {202					#[cfg(not(feature = "app-promotion"))]203					return unsupported!();204205					#[cfg(feature = "app-promotion")]206					return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_total_staked(staker).unwrap_or_default());207				}208209				#[allow(unused_variables)]210				fn total_staked_per_block(staker: CrossAccountId) -> Result<Vec<(BlockNumber, u128)>, DispatchError> {211					#[cfg(not(feature = "app-promotion"))]212					return unsupported!();213214					#[cfg(feature = "app-promotion")]215					return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_total_staked_per_block(staker));216				}217218				#[allow(unused_variables)]219				fn pending_unstake(staker: Option<CrossAccountId>) -> Result<u128, DispatchError> {220					#[cfg(not(feature = "app-promotion"))]221					return unsupported!();222223					#[cfg(feature = "app-promotion")]224					return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_pending_unstake(staker));225				}226227				#[allow(unused_variables)]228				fn pending_unstake_per_block(staker: CrossAccountId) -> Result<Vec<(BlockNumber, u128)>, DispatchError> {229					#[cfg(not(feature = "app-promotion"))]230					return unsupported!();231232					#[cfg(feature = "app-promotion")]233					return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_pending_unstake_per_block(staker))234				}235			}236237			impl sp_api::Core<Block> for Runtime {238				fn version() -> RuntimeVersion {239					VERSION240				}241242				fn execute_block(block: Block) {243					Executive::execute_block(block)244				}245246				fn initialize_block(header: &<Block as BlockT>::Header) -> ExtrinsicInclusionMode {247					Executive::initialize_block(header)248				}249			}250251			impl sp_api::Metadata<Block> for Runtime {252				fn metadata() -> OpaqueMetadata {253					OpaqueMetadata::new(Runtime::metadata().into())254				}255256				fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {257					Runtime::metadata_at_version(version)258				}259260				fn metadata_versions() -> sp_std::vec::Vec<u32> {261					Runtime::metadata_versions()262				}263			}264265			impl sp_block_builder::BlockBuilder<Block> for Runtime {266				fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {267					Executive::apply_extrinsic(extrinsic)268				}269270				fn finalize_block() -> <Block as BlockT>::Header {271					Executive::finalize_block()272				}273274				fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {275					data.create_extrinsics()276				}277278				fn check_inherents(279					block: Block,280					data: sp_inherents::InherentData,281				) -> sp_inherents::CheckInherentsResult {282					data.check_extrinsics(&block)283				}284285				// fn random_seed() -> <Block as BlockT>::Hash {286				//	   RandomnessCollectiveFlip::random_seed().0287				// }288			}289290			impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {291				fn validate_transaction(292					source: TransactionSource,293					tx: <Block as BlockT>::Extrinsic,294					hash: <Block as BlockT>::Hash,295				) -> TransactionValidity {296					Executive::validate_transaction(source, tx, hash)297				}298			}299300			impl sp_offchain::OffchainWorkerApi<Block> for Runtime {301				fn offchain_worker(header: &<Block as BlockT>::Header) {302					Executive::offchain_worker(header)303				}304			}305306			impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {307				fn chain_id() -> u64 {308					<Runtime as pallet_evm::Config>::ChainId::get()309				}310311				fn account_basic(address: H160) -> EVMAccount {312					let (account, _) = EVM::account_basic(&address);313					account314				}315316				fn gas_price() -> U256 {317					let (price, _) = <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price();318					price319				}320321				fn account_code_at(address: H160) -> Vec<u8> {322					use pallet_evm::OnMethodCall;323					<Runtime as pallet_evm::Config>::OnMethodCall::get_code(&address)324						.unwrap_or_else(|| pallet_evm::AccountCodes::<Runtime>::get(address))325				}326327				fn author() -> H160 {328					<pallet_evm::Pallet<Runtime>>::find_author()329				}330331				fn storage_at(address: H160, index: U256) -> H256 {332					let mut tmp = [0u8; 32];333					index.to_big_endian(&mut tmp);334					pallet_evm::AccountStorages::<Runtime>::get(address, H256::from_slice(&tmp[..]))335				}336337				#[allow(clippy::redundant_closure)]338				fn call(339					from: H160,340					to: H160,341					data: Vec<u8>,342					value: U256,343					gas_limit: U256,344					max_fee_per_gas: Option<U256>,345					max_priority_fee_per_gas: Option<U256>,346					nonce: Option<U256>,347					estimate: bool,348					access_list: Option<Vec<(H160, Vec<H256>)>>,349				) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {350					let config = if estimate {351						let mut config = <Runtime as pallet_evm::Config>::config().clone();352						config.estimate = true;353						Some(config)354					} else {355						None356					};357358					let is_transactional = false;359					let validate = false;360					<Runtime as pallet_evm::Config>::Runner::call(361						CrossAccountId::from_eth(from),362						to,363						data,364						value,365						gas_limit.low_u64(),366						max_fee_per_gas,367						max_priority_fee_per_gas,368						nonce,369						access_list.unwrap_or_default(),370						is_transactional,371						validate,372						// TODO we probably want to support external cost recording in non-transactional calls373						None,374						None,375376						config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),377					).map_err(|err| err.error.into())378				}379380				#[allow(clippy::redundant_closure)]381				fn create(382					from: H160,383					data: Vec<u8>,384					value: U256,385					gas_limit: U256,386					max_fee_per_gas: Option<U256>,387					max_priority_fee_per_gas: Option<U256>,388					nonce: Option<U256>,389					estimate: bool,390					access_list: Option<Vec<(H160, Vec<H256>)>>,391				) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {392					let config = if estimate {393						let mut config = <Runtime as pallet_evm::Config>::config().clone();394						config.estimate = true;395						Some(config)396					} else {397						None398					};399400					let is_transactional = false;401					let validate = false;402					<Runtime as pallet_evm::Config>::Runner::create(403						CrossAccountId::from_eth(from),404						data,405						value,406						gas_limit.low_u64(),407						max_fee_per_gas,408						max_priority_fee_per_gas,409						nonce,410						access_list.unwrap_or_default(),411						is_transactional,412						validate,413						// TODO we probably want to support external cost recording in non-transactional calls414						None,415						None,416417						config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),418					).map_err(|err| err.error.into())419				}420421				fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {422					pallet_ethereum::CurrentTransactionStatuses::<Runtime>::get()423				}424425				fn current_block() -> Option<pallet_ethereum::Block> {426					pallet_ethereum::CurrentBlock::<Runtime>::get()427				}428429				fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {430					pallet_ethereum::CurrentReceipts::<Runtime>::get()431				}432433				fn current_all() -> (434					Option<pallet_ethereum::Block>,435					Option<Vec<pallet_ethereum::Receipt>>,436					Option<Vec<TransactionStatus>>437				) {438					(439						pallet_ethereum::CurrentBlock::<Runtime>::get(),440						pallet_ethereum::CurrentReceipts::<Runtime>::get(),441						pallet_ethereum::CurrentTransactionStatuses::<Runtime>::get()442					)443				}444445				fn extrinsic_filter(xts: Vec<<Block as BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {446					xts.into_iter().filter_map(|xt| match xt.0.function {447						RuntimeCall::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),448						_ => None449					}).collect()450				}451452				fn elasticity() -> Option<Permill> {453					None454				}455456				fn gas_limit_multiplier_support() {}457458				fn pending_block(459					xts: Vec<<Block as BlockT>::Extrinsic>,460				) -> (Option<pallet_ethereum::Block>, Option<Vec<TransactionStatus>>) {461					for ext in xts.into_iter() {462						let _ = Executive::apply_extrinsic(ext);463					}464465					Ethereum::on_finalize(System::block_number() + 1);466467					(468						pallet_ethereum::CurrentBlock::<Runtime>::get(),469						pallet_ethereum::CurrentTransactionStatuses::<Runtime>::get()470					)471				}472			}473474			impl sp_session::SessionKeys<Block> for Runtime {475				fn decode_session_keys(476					encoded: Vec<u8>,477				) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {478					SessionKeys::decode_into_raw_public_keys(&encoded)479				}480481				fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {482					SessionKeys::generate(seed)483				}484			}485486			impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {487				fn slot_duration() -> sp_consensus_aura::SlotDuration {488					#[cfg(not(feature = "lookahead"))]489					{490						sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())491					}492					#[cfg(feature = "lookahead")]493					{494						sp_consensus_aura::SlotDuration::from_millis(up_common::constants::SLOT_DURATION)495					}496				}497498				fn authorities() -> Vec<AuraId> {499					Aura::authorities().to_vec()500				}501			}502503			impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {504				fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {505					ParachainSystem::collect_collation_info(header)506				}507			}508509			impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {510				fn account_nonce(account: AccountId) -> Nonce {511					System::account_nonce(account)512				}513			}514515			impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {516				fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {517					TransactionPayment::query_info(uxt, len)518				}519				fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {520					TransactionPayment::query_fee_details(uxt, len)521				}522				fn query_weight_to_fee(weight: Weight) -> Balance {523					TransactionPayment::weight_to_fee(weight)524				}525				fn query_length_to_fee(length: u32) -> Balance {526					TransactionPayment::length_to_fee(length)527				}528			}529530			#[cfg(feature = "runtime-benchmarks")]531			impl frame_benchmarking::Benchmark<Block> for Runtime {532				fn benchmark_metadata(extra: bool) -> (533					Vec<frame_benchmarking::BenchmarkList>,534					Vec<frame_support::traits::StorageInfo>,535				) {536					use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};537					use frame_support::traits::StorageInfoTrait;538					use pallet_xcm::benchmarking::Pallet as PalletXcmBenchmarks;539540					let mut list = Vec::<BenchmarkList>::new();541					list_benchmark!(list, extra, pallet_xcm, PalletXcmBenchmarks::<Runtime>);542543					list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);544					list_benchmark!(list, extra, pallet_common, Common);545					list_benchmark!(list, extra, pallet_unique, Unique);546					list_benchmark!(list, extra, pallet_structure, Structure);547					list_benchmark!(list, extra, pallet_inflation, Inflation);548					list_benchmark!(list, extra, pallet_configuration, Configuration);549550					#[cfg(feature = "app-promotion")]551					list_benchmark!(list, extra, pallet_app_promotion, AppPromotion);552553					list_benchmark!(list, extra, pallet_fungible, Fungible);554					list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);555556					#[cfg(feature = "refungible")]557					list_benchmark!(list, extra, pallet_refungible, Refungible);558559					#[cfg(feature = "collator-selection")]560					list_benchmark!(list, extra, pallet_collator_selection, CollatorSelection);561562					#[cfg(feature = "governance")]563					list_benchmark!(list, extra, pallet_identity, Identity);564565					#[cfg(feature = "foreign-assets")]566					list_benchmark!(list, extra, pallet_foreign_assets, ForeignAssets);567568					list_benchmark!(list, extra, pallet_maintenance, Maintenance);569570					// list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);571572					let storage_info = AllPalletsWithSystem::storage_info();573574					return (list, storage_info)575				}576577				fn dispatch_benchmark(578					config: frame_benchmarking::BenchmarkConfig579				) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {580					use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark};581					use sp_storage::TrackedStorageKey;582					use pallet_xcm::benchmarking::Pallet as PalletXcmBenchmarks;583584					let allowlist: Vec<TrackedStorageKey> = vec![585						// Total Issuance586						hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),587588						// Block Number589						hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),590						// Execution Phase591						hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),592						// Event Count593						hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),594						// System Events595						hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),596597						// Evm CurrentLogs598						hex_literal::hex!("1da53b775b270400e7e61ed5cbc5a146547f210cec367e9af919603343b9cb56").to_vec().into(),599600						// Transactional depth601						hex_literal::hex!("3a7472616e73616374696f6e5f6c6576656c3a").to_vec().into(),602					];603604					let mut batches = Vec::<BenchmarkBatch>::new();605					let params = (&config, &allowlist);606607					add_benchmark!(params, batches, pallet_xcm, PalletXcmBenchmarks::<Runtime>);608609					add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);610					add_benchmark!(params, batches, pallet_common, Common);611					add_benchmark!(params, batches, pallet_unique, Unique);612					add_benchmark!(params, batches, pallet_structure, Structure);613					add_benchmark!(params, batches, pallet_inflation, Inflation);614					add_benchmark!(params, batches, pallet_configuration, Configuration);615616					#[cfg(feature = "app-promotion")]617					add_benchmark!(params, batches, pallet_app_promotion, AppPromotion);618619					add_benchmark!(params, batches, pallet_fungible, Fungible);620					add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);621622					#[cfg(feature = "refungible")]623					add_benchmark!(params, batches, pallet_refungible, Refungible);624625					#[cfg(feature = "collator-selection")]626					add_benchmark!(params, batches, pallet_collator_selection, CollatorSelection);627628					#[cfg(feature = "governance")]629					add_benchmark!(params, batches, pallet_identity, Identity);630631					#[cfg(feature = "foreign-assets")]632					add_benchmark!(params, batches, pallet_foreign_assets, ForeignAssets);633634					add_benchmark!(params, batches, pallet_maintenance, Maintenance);635636					// add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);637638					if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }639					Ok(batches)640				}641			}642643			impl up_pov_estimate_rpc::PovEstimateApi<Block> for Runtime {644				#[allow(unused_variables)]645				fn pov_estimate(uxt: Vec<u8>) -> ApplyExtrinsicResult {646					#[cfg(feature = "pov-estimate")]647					{648						use parity_scale_codec::Decode;649650						let uxt_decode = <<Block as BlockT>::Extrinsic as Decode>::decode(&mut &*uxt)651							.map_err(|_| DispatchError::Other("failed to decode the extrinsic"));652653						let uxt = match uxt_decode {654							Ok(uxt) => uxt,655							Err(err) => return Ok(err.into()),656						};657658						Executive::apply_extrinsic(uxt)659					}660661					#[cfg(not(feature = "pov-estimate"))]662					return Ok(unsupported!());663				}664			}665666			#[cfg(feature = "try-runtime")]667			impl frame_try_runtime::TryRuntime<Block> for Runtime {668				fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {669					log::info!("try-runtime::on_runtime_upgrade unique-chain.");670					let weight = Executive::try_runtime_upgrade(checks).unwrap();671					(weight, $crate::config::substrate::RuntimeBlockWeights::get().max_block)672				}673674				fn execute_block(675					block: Block,676					state_root_check: bool,677					signature_check: bool,678					select: frame_try_runtime::TryStateSelect679				) -> Weight {680					log::info!(681						target: "node-runtime",682						"try-runtime: executing block {:?} / root checks: {:?} / try-state-select: {:?}",683						block.header.hash(),684						state_root_check,685						select,686					);687688					Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()689				}690			}691692			#[cfg(feature = "lookahead")]693			impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {694				fn can_build_upon(695					included_hash: <Block as BlockT>::Hash,696					slot: cumulus_primitives_aura::Slot,697				) -> bool {698					$crate::config::parachain::ConsensusHook::can_build_upon(included_hash, slot)699				}700			}701702			/// Should never be used, yet still required because of https://github.com/paritytech/polkadot-sdk/issues/27703			/// Not allowed to panic, because rpc may be called using native runtime, thus causing thread panic.704			impl fp_rpc::ConvertTransactionRuntimeApi<Block> for Runtime {705				fn convert_transaction(706					transaction: pallet_ethereum::Transaction707				) -> <Block as BlockT>::Extrinsic {708					UncheckedExtrinsic::new_unsigned(709						pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),710					)711				}712			}713		}714	}715}
after · runtime/common/runtime_apis.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#[macro_export]18macro_rules! dispatch_unique_runtime {19	($collection:ident.$method:ident($($name:ident),*) $($rest:tt)*) => {{20		let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch($collection)?;21		let dispatch = collection.as_dyn();2223		Ok::<_, DispatchError>(dispatch.$method($($name),*) $($rest)*)24	}};25}2627#[macro_export]28macro_rules! impl_common_runtime_apis {29	(30		$(31			#![custom_apis]3233			$($custom_apis:tt)+34		)?35	) => {36		use sp_std::prelude::*;37		use sp_api::impl_runtime_apis;38		use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};39		use sp_runtime::{40			Permill,41			traits::{Block as BlockT},42			transaction_validity::{TransactionSource, TransactionValidity},43			ApplyExtrinsicResult, DispatchError, ExtrinsicInclusionMode,44		};45		use frame_support::{46			genesis_builder_helper::{build_config, create_default_config},47			pallet_prelude::Weight,48			traits::OnFinalize,49		};50		use fp_rpc::TransactionStatus;51		use pallet_transaction_payment::{52			FeeDetails, RuntimeDispatchInfo,53		};54		use pallet_evm::{55			Runner, account::CrossAccountId as _,56			Account as EVMAccount, FeeCalculator,57		};58		use runtime_common::{59			sponsoring::{SponsorshipPredict, UniqueSponsorshipPredict},60			dispatch::CollectionDispatch,61			config::ethereum::CrossAccountId,62		};63		use up_data_structs::*;6465		impl_runtime_apis! {66			$($($custom_apis)+)?6768			impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId> for Runtime {69				fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {70					dispatch_unique_runtime!(collection.account_tokens(account))71				}72				fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>, DispatchError> {73					dispatch_unique_runtime!(collection.collection_tokens())74				}75				fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {76					dispatch_unique_runtime!(collection.token_exists(token))77				}7879				fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {80					dispatch_unique_runtime!(collection.token_owner(token).ok())81				}8283				fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec::<CrossAccountId>, DispatchError>  {84					dispatch_unique_runtime!(collection.token_owners(token))85				}8687				fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {88					let budget = budget::Value::new(10);8990					<pallet_structure::Pallet<Runtime>>::find_topmost_owner(collection, token, &budget)91				}92				fn token_children(collection: CollectionId, token: TokenId) -> Result<Vec<TokenChild>, DispatchError> {93					Ok(<pallet_nonfungible::Pallet<Runtime>>::token_children_ids(collection, token))94				}95				fn collection_properties(96					collection: CollectionId,97					keys: Option<Vec<Vec<u8>>>98				) -> Result<Vec<Property>, DispatchError> {99					let keys = keys.map(100						|keys| Common::bytes_keys_to_property_keys(keys)101					).transpose()?;102103					Common::filter_collection_properties(collection, keys)104				}105106				fn token_properties(107					collection: CollectionId,108					token_id: TokenId,109					keys: Option<Vec<Vec<u8>>>110				) -> Result<Vec<Property>, DispatchError> {111					let keys = keys.map(112						|keys| Common::bytes_keys_to_property_keys(keys)113					).transpose()?;114115					dispatch_unique_runtime!(collection.token_properties(token_id, keys))116				}117118				fn property_permissions(119					collection: CollectionId,120					keys: Option<Vec<Vec<u8>>>121				) -> Result<Vec<PropertyKeyPermission>, DispatchError> {122					let keys = keys.map(123						|keys| Common::bytes_keys_to_property_keys(keys)124					).transpose()?;125126					Common::filter_property_permissions(collection, keys)127				}128129				fn token_data(130					collection: CollectionId,131					token_id: TokenId,132					keys: Option<Vec<Vec<u8>>>133				) -> Result<TokenData<CrossAccountId>, DispatchError> {134					let token_data = TokenData {135						properties: Self::token_properties(collection, token_id, keys)?,136						owner: Self::token_owner(collection, token_id)?,137						pieces: Self::total_pieces(collection, token_id)?.unwrap_or(0),138					};139140					Ok(token_data)141				}142143				fn total_supply(collection: CollectionId) -> Result<u32, DispatchError> {144					dispatch_unique_runtime!(collection.total_supply())145				}146				fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {147					dispatch_unique_runtime!(collection.account_balance(account))148				}149				fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {150					dispatch_unique_runtime!(collection.balance(account, token))151				}152				fn allowance(153					collection: CollectionId,154					sender: CrossAccountId,155					spender: CrossAccountId,156					token: TokenId,157				) -> Result<u128, DispatchError> {158					dispatch_unique_runtime!(collection.allowance(sender, spender, token))159				}160161				fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {162					Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))163				}164				fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {165					Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))166				}167				fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {168					Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))169				}170				fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {171					dispatch_unique_runtime!(collection.last_token_id())172				}173				fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>, DispatchError> {174					Ok(<pallet_common::Pallet<Runtime>>::rpc_collection(collection))175				}176				fn collection_stats() -> Result<CollectionStats, DispatchError> {177					Ok(<pallet_common::Pallet<Runtime>>::collection_stats())178				}179				fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>, DispatchError> {180					Ok(<UniqueSponsorshipPredict<Runtime> as SponsorshipPredict<Runtime>>::predict(181						collection,182						account,183						token184					))185				}186187				fn effective_collection_limits(collection: CollectionId) -> Result<Option<CollectionLimits>, DispatchError> {188					Ok(<pallet_common::Pallet<Runtime>>::effective_collection_limits(collection))189				}190191				fn total_pieces(collection: CollectionId, token_id: TokenId) -> Result<Option<u128>, DispatchError> {192					dispatch_unique_runtime!(collection.total_pieces(token_id))193				}194195				fn allowance_for_all(collection: CollectionId, owner: CrossAccountId, operator: CrossAccountId) -> Result<bool, DispatchError> {196					dispatch_unique_runtime!(collection.allowance_for_all(owner, operator))197				}198			}199200			impl app_promotion_rpc::AppPromotionApi<Block, BlockNumber, CrossAccountId, AccountId> for Runtime {201				#[allow(unused_variables)]202				fn total_staked(staker: Option<CrossAccountId>) -> Result<u128, DispatchError> {203					#[cfg(not(feature = "app-promotion"))]204					return unsupported!();205206					#[cfg(feature = "app-promotion")]207					return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_total_staked(staker).unwrap_or_default());208				}209210				#[allow(unused_variables)]211				fn total_staked_per_block(staker: CrossAccountId) -> Result<Vec<(BlockNumber, u128)>, DispatchError> {212					#[cfg(not(feature = "app-promotion"))]213					return unsupported!();214215					#[cfg(feature = "app-promotion")]216					return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_total_staked_per_block(staker));217				}218219				#[allow(unused_variables)]220				fn pending_unstake(staker: Option<CrossAccountId>) -> Result<u128, DispatchError> {221					#[cfg(not(feature = "app-promotion"))]222					return unsupported!();223224					#[cfg(feature = "app-promotion")]225					return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_pending_unstake(staker));226				}227228				#[allow(unused_variables)]229				fn pending_unstake_per_block(staker: CrossAccountId) -> Result<Vec<(BlockNumber, u128)>, DispatchError> {230					#[cfg(not(feature = "app-promotion"))]231					return unsupported!();232233					#[cfg(feature = "app-promotion")]234					return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_pending_unstake_per_block(staker))235				}236			}237238			impl sp_api::Core<Block> for Runtime {239				fn version() -> RuntimeVersion {240					VERSION241				}242243				fn execute_block(block: Block) {244					Executive::execute_block(block)245				}246247				fn initialize_block(header: &<Block as BlockT>::Header) -> ExtrinsicInclusionMode {248					Executive::initialize_block(header)249				}250			}251252			impl sp_api::Metadata<Block> for Runtime {253				fn metadata() -> OpaqueMetadata {254					OpaqueMetadata::new(Runtime::metadata().into())255				}256257				fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {258					Runtime::metadata_at_version(version)259				}260261				fn metadata_versions() -> sp_std::vec::Vec<u32> {262					Runtime::metadata_versions()263				}264			}265266			impl sp_block_builder::BlockBuilder<Block> for Runtime {267				fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {268					Executive::apply_extrinsic(extrinsic)269				}270271				fn finalize_block() -> <Block as BlockT>::Header {272					Executive::finalize_block()273				}274275				fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {276					data.create_extrinsics()277				}278279				fn check_inherents(280					block: Block,281					data: sp_inherents::InherentData,282				) -> sp_inherents::CheckInherentsResult {283					data.check_extrinsics(&block)284				}285286				// fn random_seed() -> <Block as BlockT>::Hash {287				//	   RandomnessCollectiveFlip::random_seed().0288				// }289			}290291			impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {292				fn validate_transaction(293					source: TransactionSource,294					tx: <Block as BlockT>::Extrinsic,295					hash: <Block as BlockT>::Hash,296				) -> TransactionValidity {297					Executive::validate_transaction(source, tx, hash)298				}299			}300301			impl sp_offchain::OffchainWorkerApi<Block> for Runtime {302				fn offchain_worker(header: &<Block as BlockT>::Header) {303					Executive::offchain_worker(header)304				}305			}306307			impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {308				fn chain_id() -> u64 {309					<Runtime as pallet_evm::Config>::ChainId::get()310				}311312				fn account_basic(address: H160) -> EVMAccount {313					let (account, _) = EVM::account_basic(&address);314					account315				}316317				fn gas_price() -> U256 {318					let (price, _) = <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price();319					price320				}321322				fn account_code_at(address: H160) -> Vec<u8> {323					use pallet_evm::OnMethodCall;324					<Runtime as pallet_evm::Config>::OnMethodCall::get_code(&address)325						.unwrap_or_else(|| pallet_evm::AccountCodes::<Runtime>::get(address))326				}327328				fn author() -> H160 {329					<pallet_evm::Pallet<Runtime>>::find_author()330				}331332				fn storage_at(address: H160, index: U256) -> H256 {333					let mut tmp = [0u8; 32];334					index.to_big_endian(&mut tmp);335					pallet_evm::AccountStorages::<Runtime>::get(address, H256::from_slice(&tmp[..]))336				}337338				#[allow(clippy::redundant_closure)]339				fn call(340					from: H160,341					to: H160,342					data: Vec<u8>,343					value: U256,344					gas_limit: U256,345					max_fee_per_gas: Option<U256>,346					max_priority_fee_per_gas: Option<U256>,347					nonce: Option<U256>,348					estimate: bool,349					access_list: Option<Vec<(H160, Vec<H256>)>>,350				) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {351					let config = if estimate {352						let mut config = <Runtime as pallet_evm::Config>::config().clone();353						config.estimate = true;354						Some(config)355					} else {356						None357					};358359					let is_transactional = false;360					let validate = false;361					<Runtime as pallet_evm::Config>::Runner::call(362						CrossAccountId::from_eth(from),363						to,364						data,365						value,366						gas_limit.low_u64(),367						max_fee_per_gas,368						max_priority_fee_per_gas,369						nonce,370						access_list.unwrap_or_default(),371						is_transactional,372						validate,373						// TODO we probably want to support external cost recording in non-transactional calls374						None,375						None,376377						config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),378					).map_err(|err| err.error.into())379				}380381				#[allow(clippy::redundant_closure)]382				fn create(383					from: H160,384					data: Vec<u8>,385					value: U256,386					gas_limit: U256,387					max_fee_per_gas: Option<U256>,388					max_priority_fee_per_gas: Option<U256>,389					nonce: Option<U256>,390					estimate: bool,391					access_list: Option<Vec<(H160, Vec<H256>)>>,392				) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {393					let config = if estimate {394						let mut config = <Runtime as pallet_evm::Config>::config().clone();395						config.estimate = true;396						Some(config)397					} else {398						None399					};400401					let is_transactional = false;402					let validate = false;403					<Runtime as pallet_evm::Config>::Runner::create(404						CrossAccountId::from_eth(from),405						data,406						value,407						gas_limit.low_u64(),408						max_fee_per_gas,409						max_priority_fee_per_gas,410						nonce,411						access_list.unwrap_or_default(),412						is_transactional,413						validate,414						// TODO we probably want to support external cost recording in non-transactional calls415						None,416						None,417418						config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),419					).map_err(|err| err.error.into())420				}421422				fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {423					pallet_ethereum::CurrentTransactionStatuses::<Runtime>::get()424				}425426				fn current_block() -> Option<pallet_ethereum::Block> {427					pallet_ethereum::CurrentBlock::<Runtime>::get()428				}429430				fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {431					pallet_ethereum::CurrentReceipts::<Runtime>::get()432				}433434				fn current_all() -> (435					Option<pallet_ethereum::Block>,436					Option<Vec<pallet_ethereum::Receipt>>,437					Option<Vec<TransactionStatus>>438				) {439					(440						pallet_ethereum::CurrentBlock::<Runtime>::get(),441						pallet_ethereum::CurrentReceipts::<Runtime>::get(),442						pallet_ethereum::CurrentTransactionStatuses::<Runtime>::get()443					)444				}445446				fn extrinsic_filter(xts: Vec<<Block as BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {447					xts.into_iter().filter_map(|xt| match xt.0.function {448						RuntimeCall::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),449						_ => None450					}).collect()451				}452453				fn elasticity() -> Option<Permill> {454					None455				}456457				fn gas_limit_multiplier_support() {}458459				fn pending_block(460					xts: Vec<<Block as BlockT>::Extrinsic>,461				) -> (Option<pallet_ethereum::Block>, Option<Vec<TransactionStatus>>) {462					for ext in xts.into_iter() {463						let _ = Executive::apply_extrinsic(ext);464					}465466					Ethereum::on_finalize(System::block_number() + 1);467468					(469						pallet_ethereum::CurrentBlock::<Runtime>::get(),470						pallet_ethereum::CurrentTransactionStatuses::<Runtime>::get()471					)472				}473			}474475			impl sp_session::SessionKeys<Block> for Runtime {476				fn decode_session_keys(477					encoded: Vec<u8>,478				) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {479					SessionKeys::decode_into_raw_public_keys(&encoded)480				}481482				fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {483					SessionKeys::generate(seed)484				}485			}486487			impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {488				fn slot_duration() -> sp_consensus_aura::SlotDuration {489					#[cfg(not(feature = "lookahead"))]490					{491						sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())492					}493					#[cfg(feature = "lookahead")]494					{495						sp_consensus_aura::SlotDuration::from_millis(up_common::constants::SLOT_DURATION)496					}497				}498499				fn authorities() -> Vec<AuraId> {500					Aura::authorities().to_vec()501				}502			}503504			impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {505				fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {506					ParachainSystem::collect_collation_info(header)507				}508			}509510			impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {511				fn account_nonce(account: AccountId) -> Nonce {512					System::account_nonce(account)513				}514			}515516			impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {517				fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {518					TransactionPayment::query_info(uxt, len)519				}520				fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {521					TransactionPayment::query_fee_details(uxt, len)522				}523				fn query_weight_to_fee(weight: Weight) -> Balance {524					TransactionPayment::weight_to_fee(weight)525				}526				fn query_length_to_fee(length: u32) -> Balance {527					TransactionPayment::length_to_fee(length)528				}529			}530531			#[cfg(feature = "runtime-benchmarks")]532			impl frame_benchmarking::Benchmark<Block> for Runtime {533				fn benchmark_metadata(extra: bool) -> (534					Vec<frame_benchmarking::BenchmarkList>,535					Vec<frame_support::traits::StorageInfo>,536				) {537					use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};538					use frame_support::traits::StorageInfoTrait;539					use pallet_xcm::benchmarking::Pallet as PalletXcmBenchmarks;540541					let mut list = Vec::<BenchmarkList>::new();542					list_benchmark!(list, extra, pallet_xcm, PalletXcmBenchmarks::<Runtime>);543544					list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);545					list_benchmark!(list, extra, pallet_common, Common);546					list_benchmark!(list, extra, pallet_unique, Unique);547					list_benchmark!(list, extra, pallet_structure, Structure);548					list_benchmark!(list, extra, pallet_inflation, Inflation);549					list_benchmark!(list, extra, pallet_configuration, Configuration);550551					#[cfg(feature = "app-promotion")]552					list_benchmark!(list, extra, pallet_app_promotion, AppPromotion);553554					list_benchmark!(list, extra, pallet_fungible, Fungible);555					list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);556557					#[cfg(feature = "refungible")]558					list_benchmark!(list, extra, pallet_refungible, Refungible);559560					#[cfg(feature = "collator-selection")]561					list_benchmark!(list, extra, pallet_collator_selection, CollatorSelection);562563					#[cfg(feature = "governance")]564					list_benchmark!(list, extra, pallet_identity, Identity);565566					#[cfg(feature = "foreign-assets")]567					list_benchmark!(list, extra, pallet_foreign_assets, ForeignAssets);568569					list_benchmark!(list, extra, pallet_maintenance, Maintenance);570571					// list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);572573					let storage_info = AllPalletsWithSystem::storage_info();574575					return (list, storage_info)576				}577578				fn dispatch_benchmark(579					config: frame_benchmarking::BenchmarkConfig580				) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {581					use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark};582					use sp_storage::TrackedStorageKey;583					use pallet_xcm::benchmarking::Pallet as PalletXcmBenchmarks;584585					let allowlist: Vec<TrackedStorageKey> = vec![586						// Total Issuance587						hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),588589						// Block Number590						hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),591						// Execution Phase592						hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),593						// Event Count594						hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),595						// System Events596						hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),597598						// Evm CurrentLogs599						hex_literal::hex!("1da53b775b270400e7e61ed5cbc5a146547f210cec367e9af919603343b9cb56").to_vec().into(),600601						// Transactional depth602						hex_literal::hex!("3a7472616e73616374696f6e5f6c6576656c3a").to_vec().into(),603					];604605					let mut batches = Vec::<BenchmarkBatch>::new();606					let params = (&config, &allowlist);607608					add_benchmark!(params, batches, pallet_xcm, PalletXcmBenchmarks::<Runtime>);609610					add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);611					add_benchmark!(params, batches, pallet_common, Common);612					add_benchmark!(params, batches, pallet_unique, Unique);613					add_benchmark!(params, batches, pallet_structure, Structure);614					add_benchmark!(params, batches, pallet_inflation, Inflation);615					add_benchmark!(params, batches, pallet_configuration, Configuration);616617					#[cfg(feature = "app-promotion")]618					add_benchmark!(params, batches, pallet_app_promotion, AppPromotion);619620					add_benchmark!(params, batches, pallet_fungible, Fungible);621					add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);622623					#[cfg(feature = "refungible")]624					add_benchmark!(params, batches, pallet_refungible, Refungible);625626					#[cfg(feature = "collator-selection")]627					add_benchmark!(params, batches, pallet_collator_selection, CollatorSelection);628629					#[cfg(feature = "governance")]630					add_benchmark!(params, batches, pallet_identity, Identity);631632					#[cfg(feature = "foreign-assets")]633					add_benchmark!(params, batches, pallet_foreign_assets, ForeignAssets);634635					add_benchmark!(params, batches, pallet_maintenance, Maintenance);636637					// add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);638639					if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }640					Ok(batches)641				}642			}643644			impl up_pov_estimate_rpc::PovEstimateApi<Block> for Runtime {645				#[allow(unused_variables)]646				fn pov_estimate(uxt: Vec<u8>) -> ApplyExtrinsicResult {647					#[cfg(feature = "pov-estimate")]648					{649						use parity_scale_codec::Decode;650651						let uxt_decode = <<Block as BlockT>::Extrinsic as Decode>::decode(&mut &*uxt)652							.map_err(|_| DispatchError::Other("failed to decode the extrinsic"));653654						let uxt = match uxt_decode {655							Ok(uxt) => uxt,656							Err(err) => return Ok(err.into()),657						};658659						Executive::apply_extrinsic(uxt)660					}661662					#[cfg(not(feature = "pov-estimate"))]663					return Ok(unsupported!());664				}665			}666667			#[cfg(feature = "try-runtime")]668			impl frame_try_runtime::TryRuntime<Block> for Runtime {669				fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {670					log::info!("try-runtime::on_runtime_upgrade unique-chain.");671					let weight = Executive::try_runtime_upgrade(checks).unwrap();672					(weight, $crate::config::substrate::RuntimeBlockWeights::get().max_block)673				}674675				fn execute_block(676					block: Block,677					state_root_check: bool,678					signature_check: bool,679					select: frame_try_runtime::TryStateSelect680				) -> Weight {681					log::info!(682						target: "node-runtime",683						"try-runtime: executing block {:?} / root checks: {:?} / try-state-select: {:?}",684						block.header.hash(),685						state_root_check,686						select,687					);688689					Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()690				}691			}692693			#[cfg(feature = "lookahead")]694			impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {695				fn can_build_upon(696					included_hash: <Block as BlockT>::Hash,697					slot: cumulus_primitives_aura::Slot,698				) -> bool {699					$crate::config::parachain::ConsensusHook::can_build_upon(included_hash, slot)700				}701			}702703			/// Should never be used, yet still required because of https://github.com/paritytech/polkadot-sdk/issues/27704			/// Not allowed to panic, because rpc may be called using native runtime, thus causing thread panic.705			impl fp_rpc::ConvertTransactionRuntimeApi<Block> for Runtime {706				fn convert_transaction(707					transaction: pallet_ethereum::Transaction708				) -> <Block as BlockT>::Extrinsic {709					UncheckedExtrinsic::new_unsigned(710						pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),711					)712				}713			}714715			impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {716				fn create_default_config() -> Vec<u8> {717					create_default_config::<RuntimeGenesisConfig>()718				}719720				fn build_config(config: Vec<u8>) -> sp_genesis_builder::Result {721					build_config::<RuntimeGenesisConfig>(config)722				}723			}724		}725	}726}
modifiedruntime/opal/Cargo.tomldiffbeforeafterboth
--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -146,6 +146,7 @@
 	'sp-storage/std',
 	'sp-transaction-pool/std',
 	'sp-version/std',
+	'sp-genesis-builder/std',
 	'staging-parachain-info/std',
 	'staging-xcm-builder/std',
 	'staging-xcm-executor/std',
@@ -295,6 +296,7 @@
 sp-storage = { workspace = true }
 sp-transaction-pool = { workspace = true }
 sp-version = { workspace = true }
+sp-genesis-builder = { workspace = true }
 staging-parachain-info = { workspace = true }
 staging-xcm = { workspace = true }
 staging-xcm-builder = { workspace = true }
modifiedruntime/quartz/Cargo.tomldiffbeforeafterboth
--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -145,6 +145,7 @@
 	'sp-std/std',
 	'sp-transaction-pool/std',
 	'sp-version/std',
+	'sp-genesis-builder/std',
 	'staging-parachain-info/std',
 	'staging-xcm-builder/std',
 	'staging-xcm-executor/std',
@@ -283,6 +284,7 @@
 sp-storage = { workspace = true }
 sp-transaction-pool = { workspace = true }
 sp-version = { workspace = true }
+sp-genesis-builder = { workspace = true }
 staging-parachain-info = { workspace = true }
 staging-xcm = { workspace = true }
 staging-xcm-builder = { workspace = true }
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -143,6 +143,7 @@
 	'sp-std/std',
 	'sp-transaction-pool/std',
 	'sp-version/std',
+	'sp-genesis-builder/std',
 	'staging-parachain-info/std',
 	'staging-xcm-builder/std',
 	'staging-xcm-executor/std',
@@ -287,6 +288,7 @@
 sp-storage = { workspace = true }
 sp-transaction-pool = { workspace = true }
 sp-version = { workspace = true }
+sp-genesis-builder = { workspace = true }
 staging-parachain-info = { workspace = true }
 staging-xcm = { workspace = true }
 staging-xcm-builder = { workspace = true }