git.delta.rocks / unique-network / refs/commits / 081dbb6ae4fb

difftreelog

feat Separate rpc calls to own group

Trubnikov Sergey2022-09-01parent: #33ed679.patch.diff
in: master

31 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -113,6 +113,20 @@
 checksum = "508b352bb5c066aac251f6daf6b36eccd03e8a88e8081cd44959ea277a3af9a8"
 
 [[package]]
+name = "app-promotion-rpc"
+version = "0.1.0"
+dependencies = [
+ "pallet-common",
+ "pallet-evm",
+ "parity-scale-codec 3.1.5",
+ "sp-api",
+ "sp-core",
+ "sp-runtime",
+ "sp-std",
+ "up-data-structs",
+]
+
+[[package]]
 name = "approx"
 version = "0.5.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -5127,6 +5141,7 @@
 name = "opal-runtime"
 version = "0.9.27"
 dependencies = [
+ "app-promotion-rpc",
  "cumulus-pallet-aura-ext",
  "cumulus-pallet-dmp-queue",
  "cumulus-pallet-parachain-system",
@@ -8358,6 +8373,7 @@
 name = "quartz-runtime"
 version = "0.9.27"
 dependencies = [
+ "app-promotion-rpc",
  "cumulus-pallet-aura-ext",
  "cumulus-pallet-dmp-queue",
  "cumulus-pallet-parachain-system",
@@ -8381,6 +8397,7 @@
  "hex-literal",
  "log",
  "orml-vesting",
+ "pallet-app-promotion",
  "pallet-aura",
  "pallet-balances",
  "pallet-base-fee",
@@ -12132,6 +12149,7 @@
 version = "0.1.3"
 dependencies = [
  "anyhow",
+ "app-promotion-rpc",
  "jsonrpsee",
  "pallet-common",
  "pallet-evm",
@@ -12210,6 +12228,7 @@
 name = "unique-node"
 version = "0.9.27"
 dependencies = [
+ "app-promotion-rpc",
  "clap",
  "cumulus-client-cli",
  "cumulus-client-collator",
@@ -12298,6 +12317,7 @@
 name = "unique-rpc"
 version = "0.1.1"
 dependencies = [
+ "app-promotion-rpc",
  "fc-db",
  "fc-mapping-sync",
  "fc-rpc",
@@ -12347,6 +12367,7 @@
 name = "unique-runtime"
 version = "0.9.27"
 dependencies = [
+ "app-promotion-rpc",
  "cumulus-pallet-aura-ext",
  "cumulus-pallet-dmp-queue",
  "cumulus-pallet-parachain-system",
@@ -12370,6 +12391,7 @@
  "hex-literal",
  "log",
  "orml-vesting",
+ "pallet-app-promotion",
  "pallet-aura",
  "pallet-balances",
  "pallet-base-fee",
modifiedclient/rpc/Cargo.tomldiffbeforeafterboth
--- a/client/rpc/Cargo.toml
+++ b/client/rpc/Cargo.toml
@@ -8,6 +8,7 @@
 pallet-common = { default-features = false, path = '../../pallets/common' }
 up-data-structs = { default-features = false, path = '../../primitives/data-structs' }
 up-rpc = { path = "../../primitives/rpc" }
+app-promotion-rpc = { path = "../../primitives/app_promotion_rpc"}
 rmrk-rpc = { path = "../../primitives/rmrk-rpc" }
 codec = { package = "parity-scale-codec", version = "3.1.2" }
 jsonrpsee = { version = "0.14.0", features = ["server", "macros"] }
modifiedclient/rpc/src/lib.rsdiffbeforeafterboth
--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -31,6 +31,7 @@
 use sp_api::{BlockId, BlockT, ProvideRuntimeApi, ApiExt};
 use sp_blockchain::HeaderBackend;
 use up_rpc::UniqueApi as UniqueRuntimeApi;
+use app_promotion_rpc::AppPromotionApi as AppPromotionRuntimeApi;
 
 // RMRK
 use rmrk_rpc::RmrkApi as RmrkRuntimeApi;
@@ -38,6 +39,7 @@
 	RmrkCollectionId, RmrkNftId, RmrkBaseId, RmrkNftChild, RmrkThemeName, RmrkResourceId,
 };
 
+pub use app_promotion_unique_rpc::AppPromotionApiServer;
 pub use rmrk_unique_rpc::RmrkApiServer;
 
 #[rpc(server)]
@@ -244,39 +246,48 @@
 		token_id: TokenId,
 		at: Option<BlockHash>,
 	) -> Result<Option<String>>;
+}
+
+mod app_promotion_unique_rpc {
+	use super::*;
+	
+	#[rpc(server)]
+	#[async_trait]
+	pub trait AppPromotionApi<BlockHash, BlockNumber, CrossAccountId, AccountId> {
+		/// Returns the total amount of staked tokens.
+		#[method(name = "appPromotion_totalStaked")]
+		fn total_staked(&self, staker: Option<CrossAccountId>, at: Option<BlockHash>)
+			-> Result<String>;
 
-	/// Returns the total amount of staked tokens.
-	#[method(name = "unique_totalStaked")]
-	fn total_staked(&self, staker: Option<CrossAccountId>, at: Option<BlockHash>)
-		-> Result<String>;
+		///Returns the total amount of staked tokens per block when staked.
+		#[method(name = "appPromotion_totalStakedPerBlock")]
+		fn total_staked_per_block(
+			&self,
+			staker: CrossAccountId,
+			at: Option<BlockHash>,
+		) -> Result<Vec<(BlockNumber, String)>>;
 
-	///Returns the total amount of staked tokens per block when staked.
-	#[method(name = "unique_totalStakedPerBlock")]
-	fn total_staked_per_block(
-		&self,
-		staker: CrossAccountId,
-		at: Option<BlockHash>,
-	) -> Result<Vec<(BlockNumber, String)>>;
+		/// Returns the total amount locked by staking tokens.
+		#[method(name = "appPromotion_totalStakingLocked")]
+		fn total_staking_locked(&self, staker: CrossAccountId, at: Option<BlockHash>)
+			-> Result<String>;
 
-	/// Returns the total amount locked by staking tokens.
-	#[method(name = "unique_totalStakingLocked")]
-	fn total_staking_locked(&self, staker: CrossAccountId, at: Option<BlockHash>)
-		-> Result<String>;
+		/// Returns the total amount of tokens pending withdrawal from staking.
+		#[method(name = "appPromotion_pendingUnstake")]
+		fn pending_unstake(
+			&self,
+			staker: Option<CrossAccountId>,
+			at: Option<BlockHash>,
+		) -> Result<String>;
 
-	/// Returns the total amount of tokens pending withdrawal from staking.
-	#[method(name = "unique_pendingUnstake")]
-	fn pending_unstake(
-		&self,
-		staker: Option<CrossAccountId>,
-		at: Option<BlockHash>,
-	) -> Result<String>;
-	/// Returns the total amount of tokens pending withdrawal from staking per block.
-	#[method(name = "unique_pendingUnstakePerBlock")]
-	fn pending_unstake_per_block(
-		&self,
-		staker: CrossAccountId,
-		at: Option<BlockHash>,
-	) -> Result<Vec<(BlockNumber, String)>>;
+		/// Returns the total amount of tokens pending withdrawal from staking per block.
+		#[method(name = "appPromotion_pendingUnstakePerBlock")]
+		fn pending_unstake_per_block(
+			&self,
+			staker: CrossAccountId,
+			at: Option<BlockHash>,
+		) -> Result<Vec<(BlockNumber, String)>>;
+	}
 }
 
 mod rmrk_unique_rpc {
@@ -415,6 +426,20 @@
 	}
 }
 
+pub struct AppPromotion<C, P> {
+	client: Arc<C>,
+	_marker: std::marker::PhantomData<P>,
+}
+
+impl<C, P> AppPromotion<C, P> {
+	pub fn new(client: Arc<C>) -> Self {
+		Self {
+			client,
+			_marker: Default::default(),
+		}
+	}
+}
+
 pub struct Rmrk<C, P> {
 	client: Arc<C>,
 	_marker: std::marker::PhantomData<P>,
@@ -474,6 +499,12 @@
 	};
 }
 
+macro_rules! app_promotion_api {
+	() => {
+		dyn AppPromotionRuntimeApi<Block, BlockNumber, CrossAccountId, AccountId>
+	};
+}
+
 macro_rules! rmrk_api {
 	() => {
 		dyn RmrkRuntimeApi<Block, AccountId, CollectionInfo, NftInfo, ResourceInfo, PropertyInfo, BaseInfo, PartType, Theme>
@@ -556,7 +587,20 @@
 	pass_method!(effective_collection_limits(collection_id: CollectionId) -> Option<CollectionLimits>, unique_api);
 	pass_method!(total_pieces(collection_id: CollectionId, token_id: TokenId) -> Option<String> => |o| o.map(|number| number.to_string()) , unique_api);
 	pass_method!(token_owners(collection: CollectionId, token: TokenId) -> Vec<CrossAccountId>, unique_api);
-	pass_method!(total_staked(staker: Option<CrossAccountId>) -> String => |v| v.to_string(), unique_api);
+}
+
+impl<C, Block, BlockNumber, CrossAccountId, AccountId>
+ 	app_promotion_unique_rpc::AppPromotionApiServer<<Block as BlockT>::Hash, BlockNumber, CrossAccountId, AccountId>
+	for AppPromotion<C, Block>
+where
+	Block: BlockT,
+	BlockNumber: Decode + Member + AtLeast32BitUnsigned,
+	AccountId: Decode,
+	C: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,
+	C::Api: AppPromotionRuntimeApi<Block, BlockNumber, CrossAccountId, AccountId>,
+	CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,
+{
+	pass_method!(total_staked(staker: Option<CrossAccountId>) -> String => |v| v.to_string(), app_promotion_api);
 	pass_method!(total_staked_per_block(staker: CrossAccountId) -> Vec<(BlockNumber, String)> =>
 		|v| v
 		.into_iter()
modifiednode/cli/Cargo.tomldiffbeforeafterboth
--- a/node/cli/Cargo.toml
+++ b/node/cli/Cargo.toml
@@ -318,6 +318,7 @@
 pallet-ethereum = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.27" }
 
 unique-rpc = { default-features = false, path = "../rpc" }
+app-promotion-rpc = { path = "../../primitives/app_promotion_rpc", default-features = false}
 rmrk-rpc = { path = "../../primitives/rmrk-rpc" }
 
 [features]
modifiednode/cli/src/service.rsdiffbeforeafterboth
--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -364,6 +364,7 @@
 		+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
 		+ sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>
 		+ up_rpc::UniqueApi<Block, BlockNumber, Runtime::CrossAccountId, AccountId>
+		+ app_promotion_rpc::AppPromotionApi<Block, BlockNumber, Runtime::CrossAccountId, AccountId>
 		+ rmrk_rpc::RmrkApi<
 			Block,
 			AccountId,
@@ -665,6 +666,7 @@
 		+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
 		+ sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>
 		+ up_rpc::UniqueApi<Block, BlockNumber, Runtime::CrossAccountId, AccountId>
+		+ app_promotion_rpc::AppPromotionApi<Block, BlockNumber, Runtime::CrossAccountId, AccountId>
 		+ rmrk_rpc::RmrkApi<
 			Block,
 			AccountId,
@@ -809,6 +811,7 @@
 		+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
 		+ sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>
 		+ up_rpc::UniqueApi<Block, BlockNumber, Runtime::CrossAccountId, AccountId>
+		+ app_promotion_rpc::AppPromotionApi<Block, BlockNumber, Runtime::CrossAccountId, AccountId>
 		+ rmrk_rpc::RmrkApi<
 			Block,
 			AccountId,
modifiednode/rpc/Cargo.tomldiffbeforeafterboth
--- a/node/rpc/Cargo.toml
+++ b/node/rpc/Cargo.toml
@@ -53,6 +53,7 @@
 pallet-unique = { path = "../../pallets/unique" }
 uc-rpc = { path = "../../client/rpc" }
 up-rpc = { path = "../../primitives/rpc" }
+app-promotion-rpc = { path = "../../primitives/app_promotion_rpc"}
 rmrk-rpc = { path = "../../primitives/rmrk-rpc" }
 up-data-structs = { default-features = false, path = "../../primitives/data-structs" }
 
modifiednode/rpc/src/lib.rsdiffbeforeafterboth
before · node/rpc/src/lib.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use sp_runtime::traits::BlakeTwo256;18use fc_rpc::{19	EthBlockDataCacheTask, OverrideHandle, RuntimeApiStorageOverride, SchemaV1Override,20	StorageOverride, SchemaV2Override, SchemaV3Override,21};22use jsonrpsee::RpcModule;23use fc_rpc_core::types::{FilterPool, FeeHistoryCache};24use fp_storage::EthereumStorageSchema;25use sc_client_api::{26	backend::{AuxStore, StorageProvider},27	client::BlockchainEvents,28	StateBackend, Backend,29};30use sc_finality_grandpa::{31	FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState,32};33use sc_network::NetworkService;34use sc_rpc::SubscriptionTaskExecutor;35pub use sc_rpc_api::DenyUnsafe;36use sc_transaction_pool::{ChainApi, Pool};37use sp_api::ProvideRuntimeApi;38use sp_block_builder::BlockBuilder;39use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};40use sc_service::TransactionPool;41use std::{collections::BTreeMap, sync::Arc};4243use up_common::types::opaque::{Hash, AccountId, RuntimeInstance, Index, Block, BlockNumber, Balance};4445// RMRK46use up_data_structs::{47	RmrkCollectionInfo, RmrkInstanceInfo, RmrkResourceInfo, RmrkPropertyInfo, RmrkBaseInfo,48	RmrkPartType, RmrkTheme,49};5051/// Extra dependencies for GRANDPA52pub struct GrandpaDeps<B> {53	/// Voting round info.54	pub shared_voter_state: SharedVoterState,55	/// Authority set info.56	pub shared_authority_set: SharedAuthoritySet<Hash, BlockNumber>,57	/// Receives notifications about justification events from Grandpa.58	pub justification_stream: GrandpaJustificationStream<Block>,59	/// Executor to drive the subscription manager in the Grandpa RPC handler.60	pub subscription_executor: SubscriptionTaskExecutor,61	/// Finality proof provider.62	pub finality_provider: Arc<FinalityProofProvider<B, Block>>,63}6465/// Full client dependencies.66pub struct FullDeps<C, P, SC, CA: ChainApi> {67	/// The client instance to use.68	pub client: Arc<C>,69	/// Transaction pool instance.70	pub pool: Arc<P>,71	/// Graph pool instance.72	pub graph: Arc<Pool<CA>>,73	/// The SelectChain Strategy74	pub select_chain: SC,75	/// The Node authority flag76	pub is_authority: bool,77	/// Whether to enable dev signer78	pub enable_dev_signer: bool,79	/// Network service80	pub network: Arc<NetworkService<Block, Hash>>,81	/// Whether to deny unsafe calls82	pub deny_unsafe: DenyUnsafe,83	/// EthFilterApi pool.84	pub filter_pool: Option<FilterPool>,85	/// Backend.86	pub backend: Arc<fc_db::Backend<Block>>,87	/// Maximum number of logs in a query.88	pub max_past_logs: u32,89	/// Maximum fee history cache size.90	pub fee_history_limit: u64,91	/// Fee history cache.92	pub fee_history_cache: FeeHistoryCache,93	/// Cache for Ethereum block data.94	pub block_data_cache: Arc<EthBlockDataCacheTask<Block>>,95}9697pub fn overrides_handle<C, BE, R>(client: Arc<C>) -> Arc<OverrideHandle<Block>>98where99	C: ProvideRuntimeApi<Block> + StorageProvider<Block, BE> + AuxStore,100	C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError>,101	C: Send + Sync + 'static,102	C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,103	C::Api:104		up_rpc::UniqueApi<Block, BlockNumber, <R as RuntimeInstance>::CrossAccountId, AccountId>,105	BE: Backend<Block> + 'static,106	BE::State: StateBackend<BlakeTwo256>,107	R: RuntimeInstance + Send + Sync + 'static,108{109	let mut overrides_map = BTreeMap::new();110	overrides_map.insert(111		EthereumStorageSchema::V1,112		Box::new(SchemaV1Override::new(client.clone()))113			as Box<dyn StorageOverride<_> + Send + Sync>,114	);115	overrides_map.insert(116		EthereumStorageSchema::V2,117		Box::new(SchemaV2Override::new(client.clone()))118			as Box<dyn StorageOverride<_> + Send + Sync>,119	);120	overrides_map.insert(121		EthereumStorageSchema::V3,122		Box::new(SchemaV3Override::new(client.clone()))123			as Box<dyn StorageOverride<_> + Send + Sync>,124	);125126	Arc::new(OverrideHandle {127		schemas: overrides_map,128		fallback: Box::new(RuntimeApiStorageOverride::new(client)),129	})130}131132/// Instantiate all Full RPC extensions.133pub fn create_full<C, P, SC, CA, R, A, B>(134	deps: FullDeps<C, P, SC, CA>,135	subscription_task_executor: SubscriptionTaskExecutor,136) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>137where138	C: ProvideRuntimeApi<Block> + StorageProvider<Block, B> + AuxStore,139	C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,140	C: Send + Sync + 'static,141	C: BlockchainEvents<Block>,142	C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,143	C::Api: BlockBuilder<Block>,144	// C::Api: pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber, Hash>,145	C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,146	C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,147	C::Api: fp_rpc::ConvertTransactionRuntimeApi<Block>,148	C::Api:149		up_rpc::UniqueApi<Block, BlockNumber, <R as RuntimeInstance>::CrossAccountId, AccountId>,150	C::Api: rmrk_rpc::RmrkApi<151		Block,152		AccountId,153		RmrkCollectionInfo<AccountId>,154		RmrkInstanceInfo<AccountId>,155		RmrkResourceInfo,156		RmrkPropertyInfo,157		RmrkBaseInfo<AccountId>,158		RmrkPartType,159		RmrkTheme,160	>,161	B: sc_client_api::Backend<Block> + Send + Sync + 'static,162	B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,163	P: TransactionPool<Block = Block> + 'static,164	CA: ChainApi<Block = Block> + 'static,165	R: RuntimeInstance + Send + Sync + 'static,166	<R as RuntimeInstance>::CrossAccountId: serde::Serialize,167	for<'de> <R as RuntimeInstance>::CrossAccountId: serde::Deserialize<'de>,168{169	use fc_rpc::{170		Eth, EthApiServer, EthDevSigner, EthFilter, EthFilterApiServer, EthPubSub,171		EthPubSubApiServer, EthSigner, Net, NetApiServer, Web3, Web3ApiServer,172	};173	use uc_rpc::{UniqueApiServer, Unique};174175	#[cfg(not(feature = "unique-runtime"))]176	use uc_rpc::{RmrkApiServer, Rmrk};177178	// use pallet_contracts_rpc::{Contracts, ContractsApi};179	use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};180	use substrate_frame_rpc_system::{System, SystemApiServer};181182	let mut io = RpcModule::new(());183	let FullDeps {184		client,185		pool,186		graph,187		select_chain: _,188		fee_history_limit,189		fee_history_cache,190		block_data_cache,191		enable_dev_signer,192		is_authority,193		network,194		deny_unsafe,195		filter_pool,196		backend,197		max_past_logs,198	} = deps;199200	io.merge(System::new(Arc::clone(&client), Arc::clone(&pool), deny_unsafe).into_rpc())?;201	io.merge(TransactionPayment::new(Arc::clone(&client)).into_rpc())?;202203	// io.extend_with(ContractsApi::to_delegate(Contracts::new(client.clone())));204205	let mut signers = Vec::new();206	if enable_dev_signer {207		signers.push(Box::new(EthDevSigner::new()) as Box<dyn EthSigner>);208	}209210	let overrides = overrides_handle::<_, _, R>(client.clone());211212	io.merge(213		Eth::new(214			client.clone(),215			pool.clone(),216			graph,217			Some(<R as RuntimeInstance>::get_transaction_converter()),218			network.clone(),219			signers,220			overrides.clone(),221			backend.clone(),222			is_authority,223			block_data_cache.clone(),224			fee_history_cache,225			fee_history_limit,226		)227		.into_rpc(),228	)?;229230	io.merge(Unique::new(client.clone()).into_rpc())?;231232	#[cfg(not(feature = "unique-runtime"))]233	io.merge(Rmrk::new(client.clone()).into_rpc())?;234235	if let Some(filter_pool) = filter_pool {236		io.merge(237			EthFilter::new(238				client.clone(),239				backend,240				filter_pool,241				500_usize, // max stored filters242				max_past_logs,243				block_data_cache,244			)245			.into_rpc(),246		)?;247	}248249	io.merge(250		Net::new(251			client.clone(),252			network.clone(),253			// Whether to format the `peer_count` response as Hex (default) or not.254			true,255		)256		.into_rpc(),257	)?;258259	io.merge(Web3::new(client.clone()).into_rpc())?;260261	io.merge(262		EthPubSub::new(pool, client, network, subscription_task_executor, overrides).into_rpc(),263	)?;264265	Ok(io)266}
after · node/rpc/src/lib.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use sp_runtime::traits::BlakeTwo256;18use fc_rpc::{19	EthBlockDataCacheTask, OverrideHandle, RuntimeApiStorageOverride, SchemaV1Override,20	StorageOverride, SchemaV2Override, SchemaV3Override,21};22use jsonrpsee::RpcModule;23use fc_rpc_core::types::{FilterPool, FeeHistoryCache};24use fp_storage::EthereumStorageSchema;25use sc_client_api::{26	backend::{AuxStore, StorageProvider},27	client::BlockchainEvents,28	StateBackend, Backend,29};30use sc_finality_grandpa::{31	FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState,32};33use sc_network::NetworkService;34use sc_rpc::SubscriptionTaskExecutor;35pub use sc_rpc_api::DenyUnsafe;36use sc_transaction_pool::{ChainApi, Pool};37use sp_api::ProvideRuntimeApi;38use sp_block_builder::BlockBuilder;39use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};40use sc_service::TransactionPool;41use uc_rpc::AppPromotion;42use std::{collections::BTreeMap, sync::Arc};4344use up_common::types::opaque::{Hash, AccountId, RuntimeInstance, Index, Block, BlockNumber, Balance};4546// RMRK47use up_data_structs::{48	RmrkCollectionInfo, RmrkInstanceInfo, RmrkResourceInfo, RmrkPropertyInfo, RmrkBaseInfo,49	RmrkPartType, RmrkTheme,50};5152/// Extra dependencies for GRANDPA53pub struct GrandpaDeps<B> {54	/// Voting round info.55	pub shared_voter_state: SharedVoterState,56	/// Authority set info.57	pub shared_authority_set: SharedAuthoritySet<Hash, BlockNumber>,58	/// Receives notifications about justification events from Grandpa.59	pub justification_stream: GrandpaJustificationStream<Block>,60	/// Executor to drive the subscription manager in the Grandpa RPC handler.61	pub subscription_executor: SubscriptionTaskExecutor,62	/// Finality proof provider.63	pub finality_provider: Arc<FinalityProofProvider<B, Block>>,64}6566/// Full client dependencies.67pub struct FullDeps<C, P, SC, CA: ChainApi> {68	/// The client instance to use.69	pub client: Arc<C>,70	/// Transaction pool instance.71	pub pool: Arc<P>,72	/// Graph pool instance.73	pub graph: Arc<Pool<CA>>,74	/// The SelectChain Strategy75	pub select_chain: SC,76	/// The Node authority flag77	pub is_authority: bool,78	/// Whether to enable dev signer79	pub enable_dev_signer: bool,80	/// Network service81	pub network: Arc<NetworkService<Block, Hash>>,82	/// Whether to deny unsafe calls83	pub deny_unsafe: DenyUnsafe,84	/// EthFilterApi pool.85	pub filter_pool: Option<FilterPool>,86	/// Backend.87	pub backend: Arc<fc_db::Backend<Block>>,88	/// Maximum number of logs in a query.89	pub max_past_logs: u32,90	/// Maximum fee history cache size.91	pub fee_history_limit: u64,92	/// Fee history cache.93	pub fee_history_cache: FeeHistoryCache,94	/// Cache for Ethereum block data.95	pub block_data_cache: Arc<EthBlockDataCacheTask<Block>>,96}9798pub fn overrides_handle<C, BE, R>(client: Arc<C>) -> Arc<OverrideHandle<Block>>99where100	C: ProvideRuntimeApi<Block> + StorageProvider<Block, BE> + AuxStore,101	C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError>,102	C: Send + Sync + 'static,103	C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,104	C::Api:105		up_rpc::UniqueApi<Block, BlockNumber, <R as RuntimeInstance>::CrossAccountId, AccountId>,106	BE: Backend<Block> + 'static,107	BE::State: StateBackend<BlakeTwo256>,108	R: RuntimeInstance + Send + Sync + 'static,109{110	let mut overrides_map = BTreeMap::new();111	overrides_map.insert(112		EthereumStorageSchema::V1,113		Box::new(SchemaV1Override::new(client.clone()))114			as Box<dyn StorageOverride<_> + Send + Sync>,115	);116	overrides_map.insert(117		EthereumStorageSchema::V2,118		Box::new(SchemaV2Override::new(client.clone()))119			as Box<dyn StorageOverride<_> + Send + Sync>,120	);121	overrides_map.insert(122		EthereumStorageSchema::V3,123		Box::new(SchemaV3Override::new(client.clone()))124			as Box<dyn StorageOverride<_> + Send + Sync>,125	);126127	Arc::new(OverrideHandle {128		schemas: overrides_map,129		fallback: Box::new(RuntimeApiStorageOverride::new(client)),130	})131}132133/// Instantiate all Full RPC extensions.134pub fn create_full<C, P, SC, CA, R, A, B>(135	deps: FullDeps<C, P, SC, CA>,136	subscription_task_executor: SubscriptionTaskExecutor,137) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>138where139	C: ProvideRuntimeApi<Block> + StorageProvider<Block, B> + AuxStore,140	C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,141	C: Send + Sync + 'static,142	C: BlockchainEvents<Block>,143	C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,144	C::Api: BlockBuilder<Block>,145	// C::Api: pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber, Hash>,146	C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,147	C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,148	C::Api: fp_rpc::ConvertTransactionRuntimeApi<Block>,149	C::Api:150		up_rpc::UniqueApi<Block, BlockNumber, <R as RuntimeInstance>::CrossAccountId, AccountId>,151	C::Api: app_promotion_rpc::AppPromotionApi<Block, BlockNumber, <R as RuntimeInstance>::CrossAccountId, AccountId>,152	C::Api: rmrk_rpc::RmrkApi<153		Block,154		AccountId,155		RmrkCollectionInfo<AccountId>,156		RmrkInstanceInfo<AccountId>,157		RmrkResourceInfo,158		RmrkPropertyInfo,159		RmrkBaseInfo<AccountId>,160		RmrkPartType,161		RmrkTheme,162	>,163	B: sc_client_api::Backend<Block> + Send + Sync + 'static,164	B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,165	P: TransactionPool<Block = Block> + 'static,166	CA: ChainApi<Block = Block> + 'static,167	R: RuntimeInstance + Send + Sync + 'static,168	<R as RuntimeInstance>::CrossAccountId: serde::Serialize,169	for<'de> <R as RuntimeInstance>::CrossAccountId: serde::Deserialize<'de>,170{171	use fc_rpc::{172		Eth, EthApiServer, EthDevSigner, EthFilter, EthFilterApiServer, EthPubSub,173		EthPubSubApiServer, EthSigner, Net, NetApiServer, Web3, Web3ApiServer,174	};175	use uc_rpc::{UniqueApiServer, Unique};176	use uc_rpc::{AppPromotionApiServer, AppPromotion};177178	#[cfg(not(feature = "unique-runtime"))]179	use uc_rpc::{RmrkApiServer, Rmrk};180181	// use pallet_contracts_rpc::{Contracts, ContractsApi};182	use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};183	use substrate_frame_rpc_system::{System, SystemApiServer};184185	let mut io = RpcModule::new(());186	let FullDeps {187		client,188		pool,189		graph,190		select_chain: _,191		fee_history_limit,192		fee_history_cache,193		block_data_cache,194		enable_dev_signer,195		is_authority,196		network,197		deny_unsafe,198		filter_pool,199		backend,200		max_past_logs,201	} = deps;202203	io.merge(System::new(Arc::clone(&client), Arc::clone(&pool), deny_unsafe).into_rpc())?;204	io.merge(TransactionPayment::new(Arc::clone(&client)).into_rpc())?;205206	// io.extend_with(ContractsApi::to_delegate(Contracts::new(client.clone())));207208	let mut signers = Vec::new();209	if enable_dev_signer {210		signers.push(Box::new(EthDevSigner::new()) as Box<dyn EthSigner>);211	}212213	let overrides = overrides_handle::<_, _, R>(client.clone());214215	io.merge(216		Eth::new(217			client.clone(),218			pool.clone(),219			graph,220			Some(<R as RuntimeInstance>::get_transaction_converter()),221			network.clone(),222			signers,223			overrides.clone(),224			backend.clone(),225			is_authority,226			block_data_cache.clone(),227			fee_history_cache,228			fee_history_limit,229		)230		.into_rpc(),231	)?;232233	io.merge(Unique::new(client.clone()).into_rpc())?;234235	// #[cfg(not(feature = "unique-runtime"))]236	io.merge(AppPromotion::new(client.clone()).into_rpc())?;237238	#[cfg(not(feature = "unique-runtime"))]239	io.merge(Rmrk::new(client.clone()).into_rpc())?;240241	if let Some(filter_pool) = filter_pool {242		io.merge(243			EthFilter::new(244				client.clone(),245				backend,246				filter_pool,247				500_usize, // max stored filters248				max_past_logs,249				block_data_cache,250			)251			.into_rpc(),252		)?;253	}254255	io.merge(256		Net::new(257			client.clone(),258			network.clone(),259			// Whether to format the `peer_count` response as Hex (default) or not.260			true,261		)262		.into_rpc(),263	)?;264265	io.merge(Web3::new(client.clone()).into_rpc())?;266267	io.merge(268		EthPubSub::new(pool, client, network, subscription_task_executor, overrides).into_rpc(),269	)?;270271	Ok(io)272}
addedprimitives/app_promotion_rpc/CHANGELOG.mddiffbeforeafterboth
--- /dev/null
+++ b/primitives/app_promotion_rpc/CHANGELOG.md
@@ -0,0 +1,5 @@
+# Change Log
+
+All notable changes to this project will be documented in this file.
+
+<!-- bureaucrate goes here -->
addedprimitives/app_promotion_rpc/Cargo.tomldiffbeforeafterboth
--- /dev/null
+++ b/primitives/app_promotion_rpc/Cargo.toml
@@ -0,0 +1,29 @@
+[package]
+name = "app-promotion-rpc"
+version = "0.1.0"
+license = "GPLv3"
+edition = "2021"
+
+[dependencies]
+pallet-common = { default-features = false, path = '../../pallets/common' }
+up-data-structs = { default-features = false, path = '../data-structs' }
+codec = { package = "parity-scale-codec", version = "3.1.2", default-features = false, features = [
+	"derive",
+] }
+sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
+sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
+sp-api = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
+sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.27" }
+
+[features]
+default = ["std"]
+std = [
+	"codec/std",
+	"sp-core/std",
+	"sp-std/std",
+	"sp-api/std",
+	"sp-runtime/std",
+	"pallet-common/std",
+	"up-data-structs/std",
+]
addedprimitives/app_promotion_rpc/src/lib.rsdiffbeforeafterboth
--- /dev/null
+++ b/primitives/app_promotion_rpc/src/lib.rs
@@ -0,0 +1,47 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+#![cfg_attr(not(feature = "std"), no_std)]
+
+use up_data_structs::{
+	CollectionId, TokenId, RpcCollection, CollectionStats, CollectionLimits, Property,
+	PropertyKeyPermission, TokenData, TokenChild,
+};
+
+use sp_std::vec::Vec;
+use codec::Decode;
+use sp_runtime::{
+	DispatchError,
+	traits::{AtLeast32BitUnsigned, Member},
+};
+
+type Result<T> = core::result::Result<T, DispatchError>;
+
+sp_api::decl_runtime_apis! {
+	#[api_version(2)]
+	/// Trait for generate rpc.
+	pub trait AppPromotionApi<BlockNumber ,CrossAccountId, AccountId> where
+		BlockNumber: Decode + Member + AtLeast32BitUnsigned,
+		AccountId: Decode,
+		CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,
+	{
+		fn total_staked(staker: Option<CrossAccountId>) -> Result<u128>;
+		fn total_staked_per_block(staker: CrossAccountId) -> Result<Vec<(BlockNumber, u128)>>;
+		fn total_staking_locked(staker: CrossAccountId) -> Result<u128>;
+		fn pending_unstake(staker: Option<CrossAccountId>) -> Result<u128>;
+		fn pending_unstake_per_block(staker: CrossAccountId) -> Result<Vec<(BlockNumber, u128)>>;
+	}
+}
modifiedprimitives/rpc/src/lib.rsdiffbeforeafterboth
--- a/primitives/rpc/src/lib.rs
+++ b/primitives/rpc/src/lib.rs
@@ -127,11 +127,5 @@
 		fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> Result<Option<u128>>;
 
 		fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec<CrossAccountId>>;
-		fn total_staked(staker: Option<CrossAccountId>) -> Result<u128>;
-		fn total_staked_per_block(staker: CrossAccountId) -> Result<Vec<(BlockNumber, u128)>>;
-		fn total_staking_locked(staker: CrossAccountId) -> Result<u128>;
-		fn pending_unstake(staker: Option<CrossAccountId>) -> Result<u128>;
-		fn pending_unstake_per_block(staker: CrossAccountId) -> Result<Vec<(BlockNumber, u128)>>;
-
 	}
 }
modifiedruntime/common/runtime_apis.rsdiffbeforeafterboth
--- a/runtime/common/runtime_apis.rs
+++ b/runtime/common/runtime_apis.rs
@@ -187,25 +187,47 @@
                 fn total_pieces(collection: CollectionId, token_id: TokenId) -> Result<Option<u128>, DispatchError> {
                     dispatch_unique_runtime!(collection.total_pieces(token_id))
                 }
+            }
 
+            impl app_promotion_rpc::AppPromotionApi<Block, BlockNumber, CrossAccountId, AccountId> for Runtime {
                 fn total_staked(staker: Option<CrossAccountId>) -> Result<u128, DispatchError> {
-                    Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_total_staked(staker).unwrap_or_default())
-                }
+                    #[cfg(not(feature = "app-promotion"))]
+                    return unsupported!();
 
+                    #[cfg(feature = "app-promotion")]
+                    return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_total_staked(staker).unwrap_or_default());
+                }
+                
                 fn total_staked_per_block(staker: CrossAccountId) -> Result<Vec<(BlockNumber, u128)>, DispatchError> {
-                    Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_total_staked_per_block(staker))
+                    #[cfg(not(feature = "app-promotion"))]
+                    return unsupported!();
+                    
+                    #[cfg(feature = "app-promotion")]
+                    return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_total_staked_per_block(staker));
                 }
 
                 fn total_staking_locked(staker: CrossAccountId) -> Result<u128, DispatchError> {
-                    Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_locked_balance(staker))
+                    #[cfg(not(feature = "app-promotion"))]
+                    return unsupported!();
+                    
+                    #[cfg(feature = "app-promotion")]
+                    return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_locked_balance(staker));
                 }
 
                 fn pending_unstake(staker: Option<CrossAccountId>) -> Result<u128, DispatchError> {
-                    Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_pending_unstake(staker))
+                    #[cfg(not(feature = "app-promotion"))]
+                    return unsupported!();
+                    
+                    #[cfg(feature = "app-promotion")]
+                    return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_pending_unstake(staker));
                 }
 
                 fn pending_unstake_per_block(staker: CrossAccountId) -> Result<Vec<(BlockNumber, u128)>, DispatchError> {
-                    Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_pending_unstake_per_block(staker))
+                    #[cfg(not(feature = "app-promotion"))]
+                    return unsupported!();
+                    
+                    #[cfg(feature = "app-promotion")]
+                    return Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_pending_unstake_per_block(staker))
                 }
             }
 
modifiedruntime/opal/Cargo.tomldiffbeforeafterboth
--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -83,6 +83,7 @@
     'pallet-base-fee/std',
     'fp-rpc/std',
     'up-rpc/std',
+    'app-promotion-rpc/std',
     'fp-evm-mapping/std',
     'fp-self-contained/std',
     'parachain-info/std',
@@ -414,6 +415,7 @@
 derivative = "2.2.0"
 pallet-unique = { path = '../../pallets/unique', default-features = false }
 up-rpc = { path = "../../primitives/rpc", default-features = false }
+app-promotion-rpc = { path = "../../primitives/app_promotion_rpc", default-features = false}
 rmrk-rpc = { path = "../../primitives/rmrk-rpc", default-features = false }
 fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.27" }
 pallet-inflation = { path = '../../pallets/inflation', default-features = false }
modifiedruntime/quartz/Cargo.tomldiffbeforeafterboth
--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -82,6 +82,7 @@
     'pallet-base-fee/std',
     'fp-rpc/std',
     'up-rpc/std',
+    'app-promotion-rpc/std',
     'fp-evm-mapping/std',
     'fp-self-contained/std',
     'parachain-info/std',
@@ -416,8 +417,10 @@
 derivative = "2.2.0"
 pallet-unique = { path = '../../pallets/unique', default-features = false }
 up-rpc = { path = "../../primitives/rpc", default-features = false }
+app-promotion-rpc = { path = "../../primitives/app_promotion_rpc", default-features = false}
 fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.27" }
 pallet-inflation = { path = '../../pallets/inflation', default-features = false }
+pallet-app-promotion = { path = '../../pallets/app-promotion', default-features = false }
 up-data-structs = { path = '../../primitives/data-structs', default-features = false }
 pallet-configuration = { default-features = false, path = "../../pallets/configuration" }
 pallet-common = { default-features = false, path = "../../pallets/common" }
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -83,6 +83,7 @@
     'pallet-base-fee/std',
     'fp-rpc/std',
     'up-rpc/std',
+    'app-promotion-rpc/std',
     'fp-evm-mapping/std',
     'fp-self-contained/std',
     'parachain-info/std',
@@ -409,8 +410,10 @@
 derivative = "2.2.0"
 pallet-unique = { path = '../../pallets/unique', default-features = false }
 up-rpc = { path = "../../primitives/rpc", default-features = false }
+app-promotion-rpc = { path = "../../primitives/app_promotion_rpc", default-features = false}
 rmrk-rpc = { path = "../../primitives/rmrk-rpc", default-features = false }
 pallet-inflation = { path = '../../pallets/inflation', default-features = false }
+pallet-app-promotion = { path = '../../pallets/app-promotion', default-features = false }
 up-data-structs = { path = '../../primitives/data-structs', default-features = false }
 pallet-configuration = { default-features = false, path = "../../pallets/configuration" }
 pallet-common = { default-features = false, path = "../../pallets/common" }
addedtests/src/interfaces/appPromotion/definitions.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/interfaces/appPromotion/definitions.ts
@@ -0,0 +1,66 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+type RpcParam = {
+  name: string;
+  type: string;
+  isOptional?: true;
+};
+
+const CROSS_ACCOUNT_ID_TYPE = 'PalletEvmAccountBasicCrossAccountIdRepr';
+
+const collectionParam = {name: 'collection', type: 'u32'};
+const tokenParam = {name: 'tokenId', type: 'u32'};
+const propertyKeysParam = {name: 'propertyKeys', type: 'Vec<String>', isOptional: true};
+const crossAccountParam = (name = 'account') => ({name, type: CROSS_ACCOUNT_ID_TYPE});
+const atParam = {name: 'at', type: 'Hash', isOptional: true};
+
+const fun = (description: string, params: RpcParam[], type: string) => ({
+  description,
+  params: [...params, atParam],
+  type,
+});
+
+export default {
+  types: {},
+  rpc: {
+    totalStaked: fun(
+      'Returns the total amount of staked tokens',
+      [{name: 'staker', type: CROSS_ACCOUNT_ID_TYPE, isOptional: true}],
+      'u128',
+    ),
+    totalStakedPerBlock: fun(
+      'Returns the total amount of staked tokens per block when staked',
+      [crossAccountParam('staker')],
+      'Vec<(u32, u128)>',
+    ),
+    totalStakingLocked: fun(
+      'Return the total amount locked by staking tokens',
+      [crossAccountParam('staker')],
+      'u128',
+    ),
+    pendingUnstake: fun(
+      'Returns the total amount of unstaked tokens',
+      [{name: 'staker', type: CROSS_ACCOUNT_ID_TYPE, isOptional: true}],
+      'u128',
+    ),
+    pendingUnstakePerBlock: fun(
+      'Returns the total amount of unstaked tokens per block',
+      [crossAccountParam('staker')],
+      'Vec<(u32, u128)>',
+    ),
+  },
+};
addedtests/src/interfaces/appPromotion/index.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/interfaces/appPromotion/index.ts
@@ -0,0 +1,4 @@
+// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
+/* eslint-disable */
+
+export * from './types';
addedtests/src/interfaces/appPromotion/types.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/interfaces/appPromotion/types.ts
@@ -0,0 +1,4 @@
+// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
+/* eslint-disable */
+
+export type PHANTOM_APPPROMOTION = 'appPromotion';
modifiedtests/src/interfaces/augment-api-errors.tsdiffbeforeafterboth
--- a/tests/src/interfaces/augment-api-errors.ts
+++ b/tests/src/interfaces/augment-api-errors.ts
@@ -269,7 +269,7 @@
        **/
       NoPendingSponsor: AugmentedError<ApiType>;
       /**
-       * This method is only executable by owner.
+       * This method is only executable by contract owner
        **/
       NoPermission: AugmentedError<ApiType>;
       /**
@@ -278,7 +278,13 @@
       [key: string]: AugmentedError<ApiType>;
     };
     evmMigration: {
+      /**
+       * Migration of this account is not yet started, or already finished.
+       **/
       AccountIsNotMigrating: AugmentedError<ApiType>;
+      /**
+       * Can only migrate to empty address.
+       **/
       AccountNotEmpty: AugmentedError<ApiType>;
       /**
        * Generic error
modifiedtests/src/interfaces/augment-api-query.tsdiffbeforeafterboth
--- a/tests/src/interfaces/augment-api-query.ts
+++ b/tests/src/interfaces/augment-api-query.ts
@@ -335,7 +335,7 @@
        * 
        * Currently used to store RMRK data.
        **/
-      tokenAuxProperties: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array, arg3: UpDataStructsPropertyScope | 'None' | 'Rmrk' | 'Eth' | number | Uint8Array, arg4: Bytes | string | Uint8Array) => Observable<Option<Bytes>>, [u32, u32, UpDataStructsPropertyScope, Bytes]> & QueryableStorageEntry<ApiType, [u32, u32, UpDataStructsPropertyScope, Bytes]>;
+      tokenAuxProperties: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array, arg3: UpDataStructsPropertyScope | 'None' | 'Rmrk' | number | Uint8Array, arg4: Bytes | string | Uint8Array) => Observable<Option<Bytes>>, [u32, u32, UpDataStructsPropertyScope, Bytes]> & QueryableStorageEntry<ApiType, [u32, u32, UpDataStructsPropertyScope, Bytes]>;
       /**
        * Used to enumerate token's children.
        **/
modifiedtests/src/interfaces/augment-api-rpc.tsdiffbeforeafterboth
--- a/tests/src/interfaces/augment-api-rpc.ts
+++ b/tests/src/interfaces/augment-api-rpc.ts
@@ -35,6 +35,28 @@
 
 declare module '@polkadot/rpc-core/types/jsonrpc' {
   interface RpcInterface {
+    appPromotion: {
+      /**
+       * Returns the total amount of unstaked tokens
+       **/
+      pendingUnstake: AugmentedRpc<(staker?: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u128>>;
+      /**
+       * Returns the total amount of unstaked tokens per block
+       **/
+      pendingUnstakePerBlock: AugmentedRpc<(staker: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<ITuple<[u32, u128]>>>>;
+      /**
+       * Returns the total amount of staked tokens
+       **/
+      totalStaked: AugmentedRpc<(staker?: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u128>>;
+      /**
+       * Returns the total amount of staked tokens per block when staked
+       **/
+      totalStakedPerBlock: AugmentedRpc<(staker: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<ITuple<[u32, u128]>>>>;
+      /**
+       * Return the total amount locked by staking tokens
+       **/
+      totalStakingLocked: AugmentedRpc<(staker: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u128>>;
+    };
     author: {
       /**
        * Returns true if the keystore has private keys for the given public key and key type.
@@ -702,15 +724,7 @@
        * Get the number of blocks until sponsoring a transaction is available
        **/
       nextSponsored: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, account: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<u64>>>;
-      /**
-       * Returns the total amount of unstaked tokens
-       **/
-      pendingUnstake: AugmentedRpc<(staker?: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u128>>;
       /**
-       * Returns the total amount of unstaked tokens per block
-       **/
-      pendingUnstakePerBlock: AugmentedRpc<(staker: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<ITuple<[u32, u128]>>>>;
-      /**
        * Get property permissions, optionally limited to the provided keys
        **/
       propertyPermissions: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, propertyKeys?: Vec<Text> | (Text | string)[], at?: Hash | string | Uint8Array) => Observable<Vec<UpDataStructsPropertyKeyPermission>>>;
@@ -746,18 +760,6 @@
        * Get the total amount of pieces of an RFT
        **/
       totalPieces: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<u128>>>;
-      /**
-       * Returns the total amount of staked tokens
-       **/
-      totalStaked: AugmentedRpc<(staker?: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u128>>;
-      /**
-       * Returns the total amount of staked tokens per block when staked
-       **/
-      totalStakedPerBlock: AugmentedRpc<(staker: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<ITuple<[u32, u128]>>>>;
-      /**
-       * Return the total amount locked by staking tokens
-       **/
-      totalStakingLocked: AugmentedRpc<(staker: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u128>>;
       /**
        * Get the amount of distinctive tokens present in a collection
        **/
modifiedtests/src/interfaces/augment-api-tx.tsdiffbeforeafterboth
--- a/tests/src/interfaces/augment-api-tx.ts
+++ b/tests/src/interfaces/augment-api-tx.ts
@@ -181,8 +181,21 @@
       [key: string]: SubmittableExtrinsicFunction<ApiType>;
     };
     evmMigration: {
+      /**
+       * Start contract migration, inserts contract stub at target address,
+       * and marks account as pending, allowing to insert storage
+       **/
       begin: AugmentedSubmittable<(address: H160 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [H160]>;
+      /**
+       * Finish contract migration, allows it to be called.
+       * It is not possible to alter contract storage via [`Self::set_data`]
+       * after this call.
+       **/
       finish: AugmentedSubmittable<(address: H160 | string | Uint8Array, code: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [H160, Bytes]>;
+      /**
+       * Insert items into contract storage, this method can be called
+       * multiple times
+       **/
       setData: AugmentedSubmittable<(address: H160 | string | Uint8Array, data: Vec<ITuple<[H256, H256]>> | ([H256 | string | Uint8Array, H256 | string | Uint8Array])[]) => SubmittableExtrinsic<ApiType>, [H160, Vec<ITuple<[H256, H256]>>]>;
       /**
        * Generic tx
@@ -372,7 +385,7 @@
       stopAppPromotion: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
       stopSponsoringCollection: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;
       stopSponsoringContract: AugmentedSubmittable<(contractId: H160 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [H160]>;
-      unstake: AugmentedSubmittable<(amount: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u128]>;
+      unstake: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
       /**
        * Generic tx
        **/
modifiedtests/src/interfaces/default/types.tsdiffbeforeafterboth
--- a/tests/src/interfaces/default/types.ts
+++ b/tests/src/interfaces/default/types.ts
@@ -822,9 +822,6 @@
     readonly amount: u128;
   } & Struct;
   readonly isUnstake: boolean;
-  readonly asUnstake: {
-    readonly amount: u128;
-  } & Struct;
   readonly isSponsorCollection: boolean;
   readonly asSponsorCollection: {
     readonly collectionId: u32;
@@ -2639,8 +2636,7 @@
 export interface UpDataStructsPropertyScope extends Enum {
   readonly isNone: boolean;
   readonly isRmrk: boolean;
-  readonly isEth: boolean;
-  readonly type: 'None' | 'Rmrk' | 'Eth';
+  readonly type: 'None' | 'Rmrk';
 }
 
 /** @name UpDataStructsRpcCollection */
modifiedtests/src/interfaces/definitions.tsdiffbeforeafterboth
--- a/tests/src/interfaces/definitions.ts
+++ b/tests/src/interfaces/definitions.ts
@@ -15,5 +15,6 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 export {default as unique} from './unique/definitions';
+export {default as appPromotion} from './appPromotion/definitions';
 export {default as rmrk} from './rmrk/definitions';
 export {default as default} from './default/definitions';
\ No newline at end of file
modifiedtests/src/interfaces/lookup.tsdiffbeforeafterboth
--- a/tests/src/interfaces/lookup.ts
+++ b/tests/src/interfaces/lookup.ts
@@ -2467,9 +2467,7 @@
       stake: {
         amount: 'u128',
       },
-      unstake: {
-        amount: 'u128',
-      },
+      unstake: 'Null',
       sponsor_collection: {
         collectionId: 'u32',
       },
@@ -3078,7 +3076,7 @@
    * Lookup403: up_data_structs::PropertyScope
    **/
   UpDataStructsPropertyScope: {
-    _enum: ['None', 'Rmrk', 'Eth']
+    _enum: ['None', 'Rmrk']
   },
   /**
    * Lookup405: pallet_nonfungible::pallet::Error<T>
modifiedtests/src/interfaces/types-lookup.tsdiffbeforeafterboth
--- a/tests/src/interfaces/types-lookup.ts
+++ b/tests/src/interfaces/types-lookup.ts
@@ -2675,9 +2675,6 @@
       readonly amount: u128;
     } & Struct;
     readonly isUnstake: boolean;
-    readonly asUnstake: {
-      readonly amount: u128;
-    } & Struct;
     readonly isSponsorCollection: boolean;
     readonly asSponsorCollection: {
       readonly collectionId: u32;
@@ -3238,8 +3235,7 @@
   interface UpDataStructsPropertyScope extends Enum {
     readonly isNone: boolean;
     readonly isRmrk: boolean;
-    readonly isEth: boolean;
-    readonly type: 'None' | 'Rmrk' | 'Eth';
+    readonly type: 'None' | 'Rmrk';
   }
 
   /** @name PalletNonfungibleError (405) */
modifiedtests/src/interfaces/types.tsdiffbeforeafterboth
--- a/tests/src/interfaces/types.ts
+++ b/tests/src/interfaces/types.ts
@@ -2,5 +2,6 @@
 /* eslint-disable */
 
 export * from './unique/types';
+export * from './appPromotion/types';
 export * from './rmrk/types';
 export * from './default/types';
modifiedtests/src/interfaces/unique/definitions.tsdiffbeforeafterboth
--- a/tests/src/interfaces/unique/definitions.ts
+++ b/tests/src/interfaces/unique/definitions.ts
@@ -175,30 +175,5 @@
       [collectionParam, tokenParam], 
       'Option<u128>',
     ),
-    totalStaked: fun(
-      'Returns the total amount of staked tokens',
-      [{name: 'staker', type: CROSS_ACCOUNT_ID_TYPE, isOptional: true}],
-      'u128',
-    ),
-    totalStakedPerBlock: fun(
-      'Returns the total amount of staked tokens per block when staked',
-      [crossAccountParam('staker')],
-      'Vec<(u32, u128)>',
-    ),
-    totalStakingLocked: fun(
-      'Return the total amount locked by staking tokens',
-      [crossAccountParam('staker')],
-      'u128',
-    ),
-    pendingUnstake: fun(
-      'Returns the total amount of unstaked tokens',
-      [{name: 'staker', type: CROSS_ACCOUNT_ID_TYPE, isOptional: true}],
-      'u128',
-    ),
-    pendingUnstakePerBlock: fun(
-      'Returns the total amount of unstaked tokens per block',
-      [crossAccountParam('staker')],
-      'Vec<(u32, u128)>',
-    ),
   },
 };
modifiedtests/src/substrate/substrate-api.tsdiffbeforeafterboth
--- a/tests/src/substrate/substrate-api.ts
+++ b/tests/src/substrate/substrate-api.ts
@@ -42,6 +42,7 @@
     },
     rpc: {
       unique: defs.unique.rpc,
+      appPromotion: defs.appPromotion.rpc,
       rmrk: defs.rmrk.rpc,
       eth: {
         feeHistory: {
modifiedtests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.dev.ts
+++ b/tests/src/util/playgrounds/unique.dev.ts
@@ -35,6 +35,7 @@
       },
       rpc: {
         unique: defs.unique.rpc,
+        appPromotion: defs.appPromotion.rpc,
         rmrk: defs.rmrk.rpc,
         eth: {
           feeHistory: {
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -2027,24 +2027,24 @@
   }
 
   async getTotalStaked(address?: ICrossAccountId): Promise<bigint> {
-    if (address) return (await this.helper.callRpc('api.rpc.unique.totalStaked', [address])).toBigInt();
-    return (await this.helper.callRpc('api.rpc.unique.totalStaked')).toBigInt();
+    if (address) return (await this.helper.callRpc('api.rpc.appPromotion.totalStaked', [address])).toBigInt();
+    return (await this.helper.callRpc('api.rpc.appPromotion.totalStaked')).toBigInt();
   }
 
   async getTotalStakingLocked(address: ICrossAccountId): Promise<bigint> {
-    return (await this.helper.callRpc('api.rpc.unique.totalStakingLocked', [address])).toBigInt();
+    return (await this.helper.callRpc('api.rpc.appPromotion.totalStakingLocked', [address])).toBigInt();
   }
 
   async getTotalStakedPerBlock(address: ICrossAccountId): Promise<bigint[][]> {
-    return (await this.helper.callRpc('api.rpc.unique.totalStakedPerBlock', [address])).map(([block, amount]: any[]) => [block.toBigInt(), amount.toBigInt()]);
+    return (await this.helper.callRpc('api.rpc.appPromotion.totalStakedPerBlock', [address])).map(([block, amount]: any[]) => [block.toBigInt(), amount.toBigInt()]);
   }
 
   async getPendingUnstake(address: ICrossAccountId): Promise<bigint> {
-    return (await this.helper.callRpc('api.rpc.unique.pendingUnstake', [address])).toBigInt();
+    return (await this.helper.callRpc('api.rpc.appPromotion.pendingUnstake', [address])).toBigInt();
   }
   
   async getPendingUnstakePerBlock(address: ICrossAccountId): Promise<bigint[][]> {
-    return (await this.helper.callRpc('api.rpc.unique.pendingUnstakePerBlock', [address])).map(([block, amount]: any[]) => [block.toBigInt(), amount.toBigInt()]);
+    return (await this.helper.callRpc('api.rpc.appPromotion.pendingUnstakePerBlock', [address])).map(([block, amount]: any[]) => [block.toBigInt(), amount.toBigInt()]);
   }
 }