difftreelog
Add token_data RPC
in: master
10 files changed
client/rpc/src/lib.rsdiffbeforeafterboth--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -21,7 +21,7 @@
use jsonrpc_derive::rpc;
use up_data_structs::{
RpcCollection, CollectionId, CollectionStats, CollectionLimits, TokenId, Property,
- PropertyKeyPermission,
+ PropertyKeyPermission, TokenData,
};
use sp_api::{BlockId, BlockT, ProvideRuntimeApi, ApiExt};
use sp_blockchain::HeaderBackend;
@@ -104,6 +104,15 @@
at: Option<BlockHash>,
) -> Result<Vec<PropertyKeyPermission>>;
+ #[rpc(name = "unique_tokenData")]
+ fn token_data(
+ &self,
+ collection: CollectionId,
+ token_id: TokenId,
+ keys: Vec<String>,
+ at: Option<BlockHash>,
+ ) -> Result<TokenData<CrossAccountId>>;
+
#[rpc(name = "unique_totalSupply")]
fn total_supply(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<u32>;
#[rpc(name = "unique_accountBalance")]
@@ -294,6 +303,14 @@
keys: Vec<String>
) -> Vec<PropertyKeyPermission>);
+ pass_method!(token_data(
+ collection: CollectionId,
+ token_id: TokenId,
+
+ #[map(|keys| string_keys_to_bytes_keys(keys))]
+ keys: Vec<String>,
+ ) -> TokenData<CrossAccountId>);
+
pass_method!(total_supply(collection: CollectionId) -> u32);
pass_method!(account_balance(collection: CollectionId, account: CrossAccountId) -> u32);
pass_method!(balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> String => |v| v.to_string());
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -36,7 +36,7 @@
CUSTOM_DATA_LIMIT, CollectionLimits, CustomDataLimit, CreateCollectionData, SponsorshipState,
CreateItemExData, SponsoringRateLimit, budget::Budget, COLLECTION_FIELD_LIMIT, CollectionField,
PhantomType, Property, Properties, PropertiesPermissionMap, PropertyKey, PropertyPermission,
- PropertiesError, PropertyKeyPermission,
+ PropertiesError, PropertyKeyPermission, TokenData,
};
pub use pallet::*;
use sp_core::H160;
@@ -454,6 +454,7 @@
CollectionStats,
CollectionId,
TokenId,
+ PhantomType<TokenData<T::CrossAccountId>>,
PhantomType<RpcCollection<T::AccountId>>,
),
QueryKind = OptionQuery,
@@ -843,6 +844,57 @@
Ok(())
}
+ pub fn bytes_keys_to_property_keys(keys: Vec<Vec<u8>>) -> Result<Vec<PropertyKey>, DispatchError> {
+ keys.into_iter()
+ .map(|key| -> Result<PropertyKey, DispatchError> {
+ // TODO Fix error
+ key.try_into().map_err(|_| DispatchError::Other("Can't read property key"))
+ })
+ .collect::<Result<Vec<PropertyKey>, DispatchError>>()
+ }
+
+ pub fn filter_collection_properties(
+ collection_id: CollectionId,
+ keys: Vec<PropertyKey>
+ ) -> Result<Vec<Property>, DispatchError> {
+ let properties = Self::collection_properties(collection_id);
+
+ let properties = keys.into_iter()
+ .filter_map(|key| {
+ properties.get_property(&key)
+ .map(|value| {
+ Property {
+ key,
+ value: value.clone()
+ }
+ })
+ })
+ .collect();
+
+ Ok(properties)
+ }
+
+ pub fn filter_property_permissions(
+ collection_id: CollectionId,
+ keys: Vec<PropertyKey>
+ ) -> Result<Vec<PropertyKeyPermission>, DispatchError> {
+ let permissions = Self::property_permissions(collection_id);
+
+ let key_permissions = keys.into_iter()
+ .filter_map(|key| {
+ permissions.get(&key)
+ .map(|permission| {
+ PropertyKeyPermission {
+ key,
+ permission: permission.clone()
+ }
+ })
+ })
+ .collect();
+
+ Ok(key_permissions)
+ }
+
fn set_field_raw(
collection_id: CollectionId,
field: CollectionField,
@@ -1117,7 +1169,11 @@
fn token_owner(&self, token: TokenId) -> Option<T::CrossAccountId>;
fn const_metadata(&self, token: TokenId) -> Vec<u8>;
fn variable_metadata(&self, token: TokenId) -> Vec<u8>;
-
+ fn token_properties(
+ &self,
+ token_id: TokenId,
+ keys: Vec<PropertyKey>
+ ) -> Vec<Property>;
/// Amount of unique collection tokens
fn total_supply(&self) -> u32;
/// Amount of different tokens account has (Applicable to nonfungible/refungible)
pallets/fungible/src/common.rsdiffbeforeafterboth--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -250,7 +250,7 @@
_sender: T::CrossAccountId,
_property: Vec<Property>,
) -> DispatchResultWithPostInfo {
- fail!(<Error<T>>::PropertiesNotAllowed)
+ fail!(<Error<T>>::SettingPropertiesNotAllowed)
}
fn delete_collection_properties(
@@ -258,7 +258,7 @@
_sender: &T::CrossAccountId,
_property_keys: Vec<PropertyKey>,
) -> DispatchResultWithPostInfo {
- fail!(<Error<T>>::PropertiesNotAllowed)
+ fail!(<Error<T>>::SettingPropertiesNotAllowed)
}
fn set_token_properties(
@@ -267,7 +267,7 @@
_token_id: TokenId,
_property: Vec<Property>,
) -> DispatchResultWithPostInfo {
- fail!(<Error<T>>::PropertiesNotAllowed)
+ fail!(<Error<T>>::SettingPropertiesNotAllowed)
}
fn set_property_permissions(
@@ -275,7 +275,7 @@
_sender: &T::CrossAccountId,
_property_permissions: Vec<PropertyKeyPermission>,
) -> DispatchResultWithPostInfo {
- fail!(<Error<T>>::PropertiesNotAllowed)
+ fail!(<Error<T>>::SettingPropertiesNotAllowed)
}
fn delete_token_properties(
@@ -284,7 +284,7 @@
_token_id: TokenId,
_property_keys: Vec<PropertyKey>,
) -> DispatchResultWithPostInfo {
- fail!(<Error<T>>::PropertiesNotAllowed)
+ fail!(<Error<T>>::SettingPropertiesNotAllowed)
}
fn set_variable_metadata(
@@ -336,6 +336,14 @@
Vec::new()
}
+ fn token_properties(
+ &self,
+ _token_id: TokenId,
+ _keys: Vec<PropertyKey>
+ ) -> Vec<Property> {
+ Vec::new()
+ }
+
fn total_supply(&self) -> u32 {
1
}
pallets/fungible/src/lib.rsdiffbeforeafterboth--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -61,8 +61,8 @@
FungibleItemsDontHaveData,
/// Fungible token does not support nested
FungibleDisallowsNesting,
- /// Item properties are not allowed
- PropertiesNotAllowed,
+ /// Setting item properties is not allowed
+ SettingPropertiesNotAllowed,
}
#[pallet::config]
pallets/nonfungible/src/common.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -386,6 +386,26 @@
.into_inner()
}
+ fn token_properties(
+ &self,
+ token_id: TokenId,
+ keys: Vec<PropertyKey>
+ ) -> Vec<Property> {
+ let properties = <Pallet<T>>::token_properties((self.id, token_id));
+
+ keys.into_iter()
+ .filter_map(|key| {
+ properties.get_property(&key)
+ .map(|value| {
+ Property {
+ key,
+ value: value.clone()
+ }
+ })
+ })
+ .collect()
+ }
+
fn total_supply(&self) -> u32 {
<Pallet<T>>::total_supply(self)
}
pallets/refungible/src/common.rsdiffbeforeafterboth--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -269,7 +269,7 @@
_sender: T::CrossAccountId,
_property: Vec<Property>,
) -> DispatchResultWithPostInfo {
- fail!(<Error<T>>::PropertiesNotAllowed)
+ fail!(<Error<T>>::SettingPropertiesNotAllowed)
}
fn delete_collection_properties(
@@ -277,7 +277,7 @@
_sender: &T::CrossAccountId,
_property_keys: Vec<PropertyKey>,
) -> DispatchResultWithPostInfo {
- fail!(<Error<T>>::PropertiesNotAllowed)
+ fail!(<Error<T>>::SettingPropertiesNotAllowed)
}
fn set_token_properties(
@@ -286,7 +286,7 @@
_token_id: TokenId,
_property: Vec<Property>,
) -> DispatchResultWithPostInfo {
- fail!(<Error<T>>::PropertiesNotAllowed)
+ fail!(<Error<T>>::SettingPropertiesNotAllowed)
}
fn set_property_permissions(
@@ -294,7 +294,7 @@
_sender: &T::CrossAccountId,
_property_permissions: Vec<PropertyKeyPermission>,
) -> DispatchResultWithPostInfo {
- fail!(<Error<T>>::PropertiesNotAllowed)
+ fail!(<Error<T>>::SettingPropertiesNotAllowed)
}
fn delete_token_properties(
@@ -303,7 +303,7 @@
_token_id: TokenId,
_property_keys: Vec<PropertyKey>,
) -> DispatchResultWithPostInfo {
- fail!(<Error<T>>::PropertiesNotAllowed)
+ fail!(<Error<T>>::SettingPropertiesNotAllowed)
}
fn set_variable_metadata(
@@ -363,6 +363,14 @@
.into_inner()
}
+ fn token_properties(
+ &self,
+ _token_id: TokenId,
+ _keys: Vec<PropertyKey>
+ ) -> Vec<Property> {
+ Vec::new()
+ }
+
fn total_supply(&self) -> u32 {
<Pallet<T>>::total_supply(self)
}
pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -62,8 +62,8 @@
WrongRefungiblePieces,
/// Refungible token can't nest other tokens
RefungibleDisallowsNesting,
- /// Item properties are not allowed
- PropertiesNotAllowed,
+ /// Setting item properties is not allowed
+ SettingPropertiesNotAllowed,
}
#[pallet::config]
primitives/data-structs/src/lib.rsdiffbeforeafterboth--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -173,6 +173,14 @@
}
}
+#[derive(Encode, Decode, Clone, PartialEq, TypeInfo)]
+#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
+pub struct TokenData<CrossAccountId> {
+ pub const_data: Vec<u8>,
+ pub properties: Vec<Property>,
+ pub owner: Option<CrossAccountId>,
+}
+
pub struct OverflowError;
impl From<OverflowError> for &'static str {
fn from(_: OverflowError) -> Self {
primitives/rpc/src/lib.rsdiffbeforeafterboth--- a/primitives/rpc/src/lib.rs
+++ b/primitives/rpc/src/lib.rs
@@ -18,7 +18,7 @@
use up_data_structs::{
CollectionId, TokenId, RpcCollection, CollectionStats, CollectionLimits, Property,
- PropertyKeyPermission,
+ PropertyKeyPermission, TokenData,
};
use sp_std::vec::Vec;
use codec::Decode;
@@ -57,6 +57,8 @@
properties: Vec<Vec<u8>>
) -> Result<Vec<PropertyKeyPermission>>;
+ fn token_data(collection: CollectionId, token_id: TokenId, keys: Vec<Vec<u8>>) -> Result<TokenData<CrossAccountId>>;
+
fn total_supply(collection: CollectionId) -> Result<u32>;
fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32>;
fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128>;
runtime/common/src/runtime_apis.rsdiffbeforeafterboth1#[macro_export]2macro_rules! impl_common_runtime_apis {3 (4 $(5 #![custom_apis]67 $($custom_apis:tt)+8 )?9 ) => {10 fn bytes_keys_to_property_keys(keys: Vec<Vec<u8>>) -> Result<Vec<PropertyKey>, DispatchError> {11 keys.into_iter()12 .map(|key| -> Result<PropertyKey, DispatchError> {13 key.try_into().map_err(|_| DispatchError::Other("Can't read property key"))14 })15 .collect::<Result<Vec<PropertyKey>, DispatchError>>()16 }1718 impl_runtime_apis! {19 $($($custom_apis)+)?2021 impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId> for Runtime {22 fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {23 dispatch_unique_runtime!(collection.account_tokens(account))24 }25 fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>, DispatchError> {26 dispatch_unique_runtime!(collection.collection_tokens())27 }28 fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {29 dispatch_unique_runtime!(collection.token_exists(token))30 }3132 fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {33 dispatch_unique_runtime!(collection.token_owner(token))34 }35 fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {36 let budget = up_data_structs::budget::Value::new(5);3738 Ok(Some(<pallet_structure::Pallet<Runtime>>::find_topmost_owner(collection, token, &budget)?))39 }40 fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {41 dispatch_unique_runtime!(collection.const_metadata(token))42 }43 fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {44 dispatch_unique_runtime!(collection.variable_metadata(token))45 }4647 fn collection_properties(48 collection: CollectionId,49 keys: Vec<Vec<u8>>50 ) -> Result<Vec<Property>, DispatchError> {51 let keys = bytes_keys_to_property_keys(keys)?;5253 let properties = pallet_common::Pallet::<Runtime>::collection_properties(collection);5455 let properties = keys.into_iter()56 .filter_map(|key| {57 properties.get_property(&key)58 .map(|value| {59 Property {60 key,61 value: value.clone()62 }63 })64 })65 .collect();6667 Ok(properties)68 }6970 fn token_properties(71 collection: CollectionId,72 token_id: TokenId,73 keys: Vec<Vec<u8>>74 ) -> Result<Vec<Property>, DispatchError> {75 let keys = bytes_keys_to_property_keys(keys)?;7677 let properties = pallet_nonfungible::Pallet::<Runtime>::token_properties((collection, token_id));7879 let properties = keys.into_iter()80 .filter_map(|key| {81 properties.get_property(&key)82 .map(|value| {83 Property {84 key,85 value: value.clone()86 }87 })88 })89 .collect();9091 Ok(properties)92 }9394 fn property_permissions(95 collection: CollectionId,96 keys: Vec<Vec<u8>>97 ) -> Result<Vec<PropertyKeyPermission>, DispatchError> {98 let keys = bytes_keys_to_property_keys(keys)?;99100 let permissions = pallet_common::Pallet::<Runtime>::property_permissions(collection);101102 let key_permissions = keys.into_iter()103 .filter_map(|key| {104 permissions.get(&key)105 .map(|permission| {106 PropertyKeyPermission {107 key,108 permission: permission.clone()109 }110 })111 })112 .collect();113114 Ok(key_permissions)115 }116117 fn total_supply(collection: CollectionId) -> Result<u32, DispatchError> {118 dispatch_unique_runtime!(collection.total_supply())119 }120 fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {121 dispatch_unique_runtime!(collection.account_balance(account))122 }123 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {124 dispatch_unique_runtime!(collection.balance(account, token))125 }126 fn allowance(127 collection: CollectionId,128 sender: CrossAccountId,129 spender: CrossAccountId,130 token: TokenId,131 ) -> Result<u128, DispatchError> {132 dispatch_unique_runtime!(collection.allowance(sender, spender, token))133 }134135 fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {136 Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))137 }138 fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {139 Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))140 }141 fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {142 Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))143 }144 fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {145 dispatch_unique_runtime!(collection.last_token_id())146 }147 fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>, DispatchError> {148 Ok(<pallet_common::Pallet<Runtime>>::rpc_collection(collection))149 }150 fn collection_stats() -> Result<CollectionStats, DispatchError> {151 Ok(<pallet_common::Pallet<Runtime>>::collection_stats())152 }153 fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>, DispatchError> {154 Ok(<$crate::sponsoring::UniqueSponsorshipPredict<Runtime> as155 $crate::sponsoring::SponsorshipPredict<Runtime>>::predict(156 collection,157 account,158 token))159 }160161 fn effective_collection_limits(collection: CollectionId) -> Result<Option<CollectionLimits>, DispatchError> {162 Ok(<pallet_common::Pallet<Runtime>>::effective_collection_limits(collection))163 }164 }165166 impl sp_api::Core<Block> for Runtime {167 fn version() -> RuntimeVersion {168 VERSION169 }170171 fn execute_block(block: Block) {172 Executive::execute_block(block)173 }174175 fn initialize_block(header: &<Block as BlockT>::Header) {176 Executive::initialize_block(header)177 }178 }179180 impl sp_api::Metadata<Block> for Runtime {181 fn metadata() -> OpaqueMetadata {182 OpaqueMetadata::new(Runtime::metadata().into())183 }184 }185186 impl sp_block_builder::BlockBuilder<Block> for Runtime {187 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {188 Executive::apply_extrinsic(extrinsic)189 }190191 fn finalize_block() -> <Block as BlockT>::Header {192 Executive::finalize_block()193 }194195 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {196 data.create_extrinsics()197 }198199 fn check_inherents(200 block: Block,201 data: sp_inherents::InherentData,202 ) -> sp_inherents::CheckInherentsResult {203 data.check_extrinsics(&block)204 }205206 // fn random_seed() -> <Block as BlockT>::Hash {207 // RandomnessCollectiveFlip::random_seed().0208 // }209 }210211 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {212 fn validate_transaction(213 source: TransactionSource,214 tx: <Block as BlockT>::Extrinsic,215 hash: <Block as BlockT>::Hash,216 ) -> TransactionValidity {217 Executive::validate_transaction(source, tx, hash)218 }219 }220221 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {222 fn offchain_worker(header: &<Block as BlockT>::Header) {223 Executive::offchain_worker(header)224 }225 }226227 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {228 fn chain_id() -> u64 {229 <Runtime as pallet_evm::Config>::ChainId::get()230 }231232 fn account_basic(address: H160) -> EVMAccount {233 EVM::account_basic(&address)234 }235236 fn gas_price() -> U256 {237 <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()238 }239240 fn account_code_at(address: H160) -> Vec<u8> {241 EVM::account_codes(address)242 }243244 fn author() -> H160 {245 <pallet_evm::Pallet<Runtime>>::find_author()246 }247248 fn storage_at(address: H160, index: U256) -> H256 {249 let mut tmp = [0u8; 32];250 index.to_big_endian(&mut tmp);251 EVM::account_storages(address, H256::from_slice(&tmp[..]))252 }253254 #[allow(clippy::redundant_closure)]255 fn call(256 from: H160,257 to: H160,258 data: Vec<u8>,259 value: U256,260 gas_limit: U256,261 max_fee_per_gas: Option<U256>,262 max_priority_fee_per_gas: Option<U256>,263 nonce: Option<U256>,264 estimate: bool,265 access_list: Option<Vec<(H160, Vec<H256>)>>,266 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {267 let config = if estimate {268 let mut config = <Runtime as pallet_evm::Config>::config().clone();269 config.estimate = true;270 Some(config)271 } else {272 None273 };274275 let is_transactional = false;276 <Runtime as pallet_evm::Config>::Runner::call(277 CrossAccountId::from_eth(from),278 to,279 data,280 value,281 gas_limit.low_u64(),282 max_fee_per_gas,283 max_priority_fee_per_gas,284 nonce,285 access_list.unwrap_or_default(),286 is_transactional,287 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),288 ).map_err(|err| err.into())289 }290291 #[allow(clippy::redundant_closure)]292 fn create(293 from: H160,294 data: Vec<u8>,295 value: U256,296 gas_limit: U256,297 max_fee_per_gas: Option<U256>,298 max_priority_fee_per_gas: Option<U256>,299 nonce: Option<U256>,300 estimate: bool,301 access_list: Option<Vec<(H160, Vec<H256>)>>,302 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {303 let config = if estimate {304 let mut config = <Runtime as pallet_evm::Config>::config().clone();305 config.estimate = true;306 Some(config)307 } else {308 None309 };310311 let is_transactional = false;312 <Runtime as pallet_evm::Config>::Runner::create(313 CrossAccountId::from_eth(from),314 data,315 value,316 gas_limit.low_u64(),317 max_fee_per_gas,318 max_priority_fee_per_gas,319 nonce,320 access_list.unwrap_or_default(),321 is_transactional,322 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),323 ).map_err(|err| err.into())324 }325326 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {327 Ethereum::current_transaction_statuses()328 }329330 fn current_block() -> Option<pallet_ethereum::Block> {331 Ethereum::current_block()332 }333334 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {335 Ethereum::current_receipts()336 }337338 fn current_all() -> (339 Option<pallet_ethereum::Block>,340 Option<Vec<pallet_ethereum::Receipt>>,341 Option<Vec<TransactionStatus>>342 ) {343 (344 Ethereum::current_block(),345 Ethereum::current_receipts(),346 Ethereum::current_transaction_statuses()347 )348 }349350 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {351 xts.into_iter().filter_map(|xt| match xt.0.function {352 Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),353 _ => None354 }).collect()355 }356357 fn elasticity() -> Option<Permill> {358 None359 }360 }361362 impl fp_rpc::ConvertTransactionRuntimeApi<Block> for Runtime {363 fn convert_transaction(transaction: pallet_ethereum::Transaction) -> <Block as BlockT>::Extrinsic {364 UncheckedExtrinsic::new_unsigned(365 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),366 )367 }368 }369370 impl sp_session::SessionKeys<Block> for Runtime {371 fn decode_session_keys(372 encoded: Vec<u8>,373 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {374 SessionKeys::decode_into_raw_public_keys(&encoded)375 }376377 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {378 SessionKeys::generate(seed)379 }380 }381382 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {383 fn slot_duration() -> sp_consensus_aura::SlotDuration {384 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())385 }386387 fn authorities() -> Vec<AuraId> {388 Aura::authorities().to_vec()389 }390 }391392 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {393 fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {394 ParachainSystem::collect_collation_info(header)395 }396 }397398 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {399 fn account_nonce(account: AccountId) -> Index {400 System::account_nonce(account)401 }402 }403404 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {405 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {406 TransactionPayment::query_info(uxt, len)407 }408 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {409 TransactionPayment::query_fee_details(uxt, len)410 }411 }412413 /*414 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>415 for Runtime416 {417 fn call(418 origin: AccountId,419 dest: AccountId,420 value: Balance,421 gas_limit: u64,422 input_data: Vec<u8>,423 ) -> pallet_contracts_primitives::ContractExecResult {424 Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)425 }426427 fn instantiate(428 origin: AccountId,429 endowment: Balance,430 gas_limit: u64,431 code: pallet_contracts_primitives::Code<Hash>,432 data: Vec<u8>,433 salt: Vec<u8>,434 ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>435 {436 Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)437 }438439 fn get_storage(440 address: AccountId,441 key: [u8; 32],442 ) -> pallet_contracts_primitives::GetStorageResult {443 Contracts::get_storage(address, key)444 }445446 fn rent_projection(447 address: AccountId,448 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {449 Contracts::rent_projection(address)450 }451 }452 */453454 #[cfg(feature = "runtime-benchmarks")]455 impl frame_benchmarking::Benchmark<Block> for Runtime {456 fn benchmark_metadata(extra: bool) -> (457 Vec<frame_benchmarking::BenchmarkList>,458 Vec<frame_support::traits::StorageInfo>,459 ) {460 use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};461 use frame_support::traits::StorageInfoTrait;462463 let mut list = Vec::<BenchmarkList>::new();464465 list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);466 list_benchmark!(list, extra, pallet_unique, Unique);467 list_benchmark!(list, extra, pallet_structure, Structure);468 list_benchmark!(list, extra, pallet_inflation, Inflation);469 list_benchmark!(list, extra, pallet_fungible, Fungible);470 list_benchmark!(list, extra, pallet_refungible, Refungible);471 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);472 // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);473474 let storage_info = AllPalletsReversedWithSystemFirst::storage_info();475476 return (list, storage_info)477 }478479 fn dispatch_benchmark(480 config: frame_benchmarking::BenchmarkConfig481 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {482 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};483484 let allowlist: Vec<TrackedStorageKey> = vec![485 // Block Number486 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),487 // Total Issuance488 hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),489 // Execution Phase490 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),491 // Event Count492 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),493 // System Events494 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),495496 // Transactional depth497 hex_literal::hex!("3a7472616e73616374696f6e5f6c6576656c3a").to_vec().into(),498 ];499500 let mut batches = Vec::<BenchmarkBatch>::new();501 let params = (&config, &allowlist);502503 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);504 add_benchmark!(params, batches, pallet_unique, Unique);505 add_benchmark!(params, batches, pallet_structure, Structure);506 add_benchmark!(params, batches, pallet_inflation, Inflation);507 add_benchmark!(params, batches, pallet_fungible, Fungible);508 add_benchmark!(params, batches, pallet_refungible, Refungible);509 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);510 // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);511512 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }513 Ok(batches)514 }515 }516517 #[cfg(feature = "try-runtime")]518 impl frame_try_runtime::TryRuntime<Block> for Runtime {519 fn on_runtime_upgrade() -> (Weight, Weight) {520 log::info!("try-runtime::on_runtime_upgrade unique-chain.");521 let weight = Executive::try_runtime_upgrade().unwrap();522 (weight, RuntimeBlockWeights::get().max_block)523 }524525 fn execute_block_no_check(block: Block) -> Weight {526 Executive::execute_block_no_check(block)527 }528 }529 }530 }531}1#[macro_export]2macro_rules! impl_common_runtime_apis {3 (4 $(5 #![custom_apis]67 $($custom_apis:tt)+8 )?9 ) => {10 impl_runtime_apis! {11 $($($custom_apis)+)?1213 impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId> for Runtime {14 fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {15 dispatch_unique_runtime!(collection.account_tokens(account))16 }17 fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>, DispatchError> {18 dispatch_unique_runtime!(collection.collection_tokens())19 }20 fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {21 dispatch_unique_runtime!(collection.token_exists(token))22 }2324 fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {25 dispatch_unique_runtime!(collection.token_owner(token))26 }27 fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {28 let budget = up_data_structs::budget::Value::new(5);2930 Ok(Some(<pallet_structure::Pallet<Runtime>>::find_topmost_owner(collection, token, &budget)?))31 }32 fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {33 dispatch_unique_runtime!(collection.const_metadata(token))34 }35 fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {36 dispatch_unique_runtime!(collection.variable_metadata(token))37 }3839 fn collection_properties(40 collection: CollectionId,41 keys: Vec<Vec<u8>>42 ) -> Result<Vec<Property>, DispatchError> {43 let keys = pallet_common::Pallet::<Runtime>::bytes_keys_to_property_keys(keys)?;4445 pallet_common::Pallet::<Runtime>::filter_collection_properties(collection, keys)46 }4748 fn token_properties(49 collection: CollectionId,50 token_id: TokenId,51 keys: Vec<Vec<u8>>52 ) -> Result<Vec<Property>, DispatchError> {53 let keys = pallet_common::Pallet::<Runtime>::bytes_keys_to_property_keys(keys)?;54 dispatch_unique_runtime!(collection.token_properties(token_id, keys))55 }5657 fn property_permissions(58 collection: CollectionId,59 keys: Vec<Vec<u8>>60 ) -> Result<Vec<PropertyKeyPermission>, DispatchError> {61 let keys = pallet_common::Pallet::<Runtime>::bytes_keys_to_property_keys(keys)?;6263 pallet_common::Pallet::<Runtime>::filter_property_permissions(collection, keys)64 }6566 fn token_data(67 collection: CollectionId,68 token_id: TokenId,69 keys: Vec<Vec<u8>>70 ) -> Result<TokenData<CrossAccountId>, DispatchError> {71 let token_data = TokenData {72 const_data: Self::const_metadata(collection, token_id)?,73 properties: Self::token_properties(collection, token_id, keys)?,74 owner: Self::token_owner(collection, token_id)?75 };7677 Ok(token_data)78 }7980 fn total_supply(collection: CollectionId) -> Result<u32, DispatchError> {81 dispatch_unique_runtime!(collection.total_supply())82 }83 fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {84 dispatch_unique_runtime!(collection.account_balance(account))85 }86 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {87 dispatch_unique_runtime!(collection.balance(account, token))88 }89 fn allowance(90 collection: CollectionId,91 sender: CrossAccountId,92 spender: CrossAccountId,93 token: TokenId,94 ) -> Result<u128, DispatchError> {95 dispatch_unique_runtime!(collection.allowance(sender, spender, token))96 }9798 fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {99 Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))100 }101 fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {102 Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))103 }104 fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {105 Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))106 }107 fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {108 dispatch_unique_runtime!(collection.last_token_id())109 }110 fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>, DispatchError> {111 Ok(<pallet_common::Pallet<Runtime>>::rpc_collection(collection))112 }113 fn collection_stats() -> Result<CollectionStats, DispatchError> {114 Ok(<pallet_common::Pallet<Runtime>>::collection_stats())115 }116 fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>, DispatchError> {117 Ok(<$crate::sponsoring::UniqueSponsorshipPredict<Runtime> as118 $crate::sponsoring::SponsorshipPredict<Runtime>>::predict(119 collection,120 account,121 token))122 }123124 fn effective_collection_limits(collection: CollectionId) -> Result<Option<CollectionLimits>, DispatchError> {125 Ok(<pallet_common::Pallet<Runtime>>::effective_collection_limits(collection))126 }127 }128129 impl sp_api::Core<Block> for Runtime {130 fn version() -> RuntimeVersion {131 VERSION132 }133134 fn execute_block(block: Block) {135 Executive::execute_block(block)136 }137138 fn initialize_block(header: &<Block as BlockT>::Header) {139 Executive::initialize_block(header)140 }141 }142143 impl sp_api::Metadata<Block> for Runtime {144 fn metadata() -> OpaqueMetadata {145 OpaqueMetadata::new(Runtime::metadata().into())146 }147 }148149 impl sp_block_builder::BlockBuilder<Block> for Runtime {150 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {151 Executive::apply_extrinsic(extrinsic)152 }153154 fn finalize_block() -> <Block as BlockT>::Header {155 Executive::finalize_block()156 }157158 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {159 data.create_extrinsics()160 }161162 fn check_inherents(163 block: Block,164 data: sp_inherents::InherentData,165 ) -> sp_inherents::CheckInherentsResult {166 data.check_extrinsics(&block)167 }168169 // fn random_seed() -> <Block as BlockT>::Hash {170 // RandomnessCollectiveFlip::random_seed().0171 // }172 }173174 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {175 fn validate_transaction(176 source: TransactionSource,177 tx: <Block as BlockT>::Extrinsic,178 hash: <Block as BlockT>::Hash,179 ) -> TransactionValidity {180 Executive::validate_transaction(source, tx, hash)181 }182 }183184 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {185 fn offchain_worker(header: &<Block as BlockT>::Header) {186 Executive::offchain_worker(header)187 }188 }189190 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {191 fn chain_id() -> u64 {192 <Runtime as pallet_evm::Config>::ChainId::get()193 }194195 fn account_basic(address: H160) -> EVMAccount {196 EVM::account_basic(&address)197 }198199 fn gas_price() -> U256 {200 <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()201 }202203 fn account_code_at(address: H160) -> Vec<u8> {204 EVM::account_codes(address)205 }206207 fn author() -> H160 {208 <pallet_evm::Pallet<Runtime>>::find_author()209 }210211 fn storage_at(address: H160, index: U256) -> H256 {212 let mut tmp = [0u8; 32];213 index.to_big_endian(&mut tmp);214 EVM::account_storages(address, H256::from_slice(&tmp[..]))215 }216217 #[allow(clippy::redundant_closure)]218 fn call(219 from: H160,220 to: H160,221 data: Vec<u8>,222 value: U256,223 gas_limit: U256,224 max_fee_per_gas: Option<U256>,225 max_priority_fee_per_gas: Option<U256>,226 nonce: Option<U256>,227 estimate: bool,228 access_list: Option<Vec<(H160, Vec<H256>)>>,229 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {230 let config = if estimate {231 let mut config = <Runtime as pallet_evm::Config>::config().clone();232 config.estimate = true;233 Some(config)234 } else {235 None236 };237238 let is_transactional = false;239 <Runtime as pallet_evm::Config>::Runner::call(240 CrossAccountId::from_eth(from),241 to,242 data,243 value,244 gas_limit.low_u64(),245 max_fee_per_gas,246 max_priority_fee_per_gas,247 nonce,248 access_list.unwrap_or_default(),249 is_transactional,250 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),251 ).map_err(|err| err.into())252 }253254 #[allow(clippy::redundant_closure)]255 fn create(256 from: H160,257 data: Vec<u8>,258 value: U256,259 gas_limit: U256,260 max_fee_per_gas: Option<U256>,261 max_priority_fee_per_gas: Option<U256>,262 nonce: Option<U256>,263 estimate: bool,264 access_list: Option<Vec<(H160, Vec<H256>)>>,265 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {266 let config = if estimate {267 let mut config = <Runtime as pallet_evm::Config>::config().clone();268 config.estimate = true;269 Some(config)270 } else {271 None272 };273274 let is_transactional = false;275 <Runtime as pallet_evm::Config>::Runner::create(276 CrossAccountId::from_eth(from),277 data,278 value,279 gas_limit.low_u64(),280 max_fee_per_gas,281 max_priority_fee_per_gas,282 nonce,283 access_list.unwrap_or_default(),284 is_transactional,285 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),286 ).map_err(|err| err.into())287 }288289 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {290 Ethereum::current_transaction_statuses()291 }292293 fn current_block() -> Option<pallet_ethereum::Block> {294 Ethereum::current_block()295 }296297 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {298 Ethereum::current_receipts()299 }300301 fn current_all() -> (302 Option<pallet_ethereum::Block>,303 Option<Vec<pallet_ethereum::Receipt>>,304 Option<Vec<TransactionStatus>>305 ) {306 (307 Ethereum::current_block(),308 Ethereum::current_receipts(),309 Ethereum::current_transaction_statuses()310 )311 }312313 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {314 xts.into_iter().filter_map(|xt| match xt.0.function {315 Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),316 _ => None317 }).collect()318 }319320 fn elasticity() -> Option<Permill> {321 None322 }323 }324325 impl fp_rpc::ConvertTransactionRuntimeApi<Block> for Runtime {326 fn convert_transaction(transaction: pallet_ethereum::Transaction) -> <Block as BlockT>::Extrinsic {327 UncheckedExtrinsic::new_unsigned(328 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),329 )330 }331 }332333 impl sp_session::SessionKeys<Block> for Runtime {334 fn decode_session_keys(335 encoded: Vec<u8>,336 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {337 SessionKeys::decode_into_raw_public_keys(&encoded)338 }339340 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {341 SessionKeys::generate(seed)342 }343 }344345 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {346 fn slot_duration() -> sp_consensus_aura::SlotDuration {347 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())348 }349350 fn authorities() -> Vec<AuraId> {351 Aura::authorities().to_vec()352 }353 }354355 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {356 fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {357 ParachainSystem::collect_collation_info(header)358 }359 }360361 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {362 fn account_nonce(account: AccountId) -> Index {363 System::account_nonce(account)364 }365 }366367 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {368 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {369 TransactionPayment::query_info(uxt, len)370 }371 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {372 TransactionPayment::query_fee_details(uxt, len)373 }374 }375376 /*377 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>378 for Runtime379 {380 fn call(381 origin: AccountId,382 dest: AccountId,383 value: Balance,384 gas_limit: u64,385 input_data: Vec<u8>,386 ) -> pallet_contracts_primitives::ContractExecResult {387 Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)388 }389390 fn instantiate(391 origin: AccountId,392 endowment: Balance,393 gas_limit: u64,394 code: pallet_contracts_primitives::Code<Hash>,395 data: Vec<u8>,396 salt: Vec<u8>,397 ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>398 {399 Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)400 }401402 fn get_storage(403 address: AccountId,404 key: [u8; 32],405 ) -> pallet_contracts_primitives::GetStorageResult {406 Contracts::get_storage(address, key)407 }408409 fn rent_projection(410 address: AccountId,411 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {412 Contracts::rent_projection(address)413 }414 }415 */416417 #[cfg(feature = "runtime-benchmarks")]418 impl frame_benchmarking::Benchmark<Block> for Runtime {419 fn benchmark_metadata(extra: bool) -> (420 Vec<frame_benchmarking::BenchmarkList>,421 Vec<frame_support::traits::StorageInfo>,422 ) {423 use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};424 use frame_support::traits::StorageInfoTrait;425426 let mut list = Vec::<BenchmarkList>::new();427428 list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);429 list_benchmark!(list, extra, pallet_unique, Unique);430 list_benchmark!(list, extra, pallet_structure, Structure);431 list_benchmark!(list, extra, pallet_inflation, Inflation);432 list_benchmark!(list, extra, pallet_fungible, Fungible);433 list_benchmark!(list, extra, pallet_refungible, Refungible);434 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);435 // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);436437 let storage_info = AllPalletsReversedWithSystemFirst::storage_info();438439 return (list, storage_info)440 }441442 fn dispatch_benchmark(443 config: frame_benchmarking::BenchmarkConfig444 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {445 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};446447 let allowlist: Vec<TrackedStorageKey> = vec![448 // Block Number449 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),450 // Total Issuance451 hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),452 // Execution Phase453 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),454 // Event Count455 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),456 // System Events457 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),458459 // Transactional depth460 hex_literal::hex!("3a7472616e73616374696f6e5f6c6576656c3a").to_vec().into(),461 ];462463 let mut batches = Vec::<BenchmarkBatch>::new();464 let params = (&config, &allowlist);465466 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);467 add_benchmark!(params, batches, pallet_unique, Unique);468 add_benchmark!(params, batches, pallet_structure, Structure);469 add_benchmark!(params, batches, pallet_inflation, Inflation);470 add_benchmark!(params, batches, pallet_fungible, Fungible);471 add_benchmark!(params, batches, pallet_refungible, Refungible);472 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);473 // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);474475 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }476 Ok(batches)477 }478 }479480 #[cfg(feature = "try-runtime")]481 impl frame_try_runtime::TryRuntime<Block> for Runtime {482 fn on_runtime_upgrade() -> (Weight, Weight) {483 log::info!("try-runtime::on_runtime_upgrade unique-chain.");484 let weight = Executive::try_runtime_upgrade().unwrap();485 (weight, RuntimeBlockWeights::get().max_block)486 }487488 fn execute_block_no_check(block: Block) -> Weight {489 Executive::execute_block_no_check(block)490 }491 }492 }493 }494}