difftreelog
feat split large fields out of Collection
in: master
7 files changed
client/rpc/src/lib.rsdiffbeforeafterboth--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -19,7 +19,7 @@
use codec::Decode;
use jsonrpc_core::{Error as RpcError, ErrorCode, Result};
use jsonrpc_derive::rpc;
-use up_data_structs::{Collection, CollectionId, CollectionStats, CollectionLimits, TokenId};
+use up_data_structs::{RpcCollection, Collection, CollectionId, CollectionStats, CollectionLimits, TokenId};
use sp_api::{BlockId, BlockT, ProvideRuntimeApi, ApiExt};
use sp_blockchain::HeaderBackend;
use up_rpc::UniqueApi as UniqueRuntimeApi;
@@ -116,7 +116,7 @@
&self,
collection: CollectionId,
at: Option<BlockHash>,
- ) -> Result<Option<Collection<AccountId>>>;
+ ) -> Result<Option<RpcCollection<AccountId>>>;
#[rpc(name = "unique_collectionStats")]
fn collection_stats(&self, at: Option<BlockHash>) -> Result<CollectionStats>;
@@ -235,7 +235,7 @@
pass_method!(allowlist(collection: CollectionId) -> Vec<CrossAccountId>);
pass_method!(allowed(collection: CollectionId, user: CrossAccountId) -> bool);
pass_method!(last_token_id(collection: CollectionId) -> TokenId);
- pass_method!(collection_by_id(collection: CollectionId) -> Option<Collection<AccountId>>);
+ pass_method!(collection_by_id(collection: CollectionId) -> Option<RpcCollection<AccountId>>);
pass_method!(collection_stats() -> CollectionStats);
pass_method!(next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Option<u64>);
pass_method!(effective_collection_limits(collection_id: CollectionId) -> Option<CollectionLimits>);
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -29,11 +29,11 @@
};
use pallet_evm::GasWeightMapping;
use up_data_structs::{
- COLLECTION_NUMBER_LIMIT, Collection, CollectionId, CreateItemData, MAX_TOKEN_PREFIX_LENGTH,
+ COLLECTION_NUMBER_LIMIT, Collection, RpcCollection, CollectionId, CreateItemData, MAX_TOKEN_PREFIX_LENGTH,
COLLECTION_ADMINS_LIMIT, MetaUpdatePermission, TokenId, CollectionStats, MAX_TOKEN_OWNERSHIP,
CollectionMode, NFT_SPONSOR_TRANSFER_TIMEOUT, FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,
REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, MAX_SPONSOR_TIMEOUT, CUSTOM_DATA_LIMIT, CollectionLimits,
- CustomDataLimit, CreateCollectionData, SponsorshipState, CreateItemExData, SponsoringRateLimit, budget::Budget,
+ CustomDataLimit, CreateCollectionData, SponsorshipState, CreateItemExData, SponsoringRateLimit, budget::Budget, COLLECTION_FIELD_LIMIT, CollectionField,
};
pub use pallet::*;
use sp_core::H160;
@@ -352,6 +352,9 @@
OnlyOwnerAllowedToNest,
/// Only tokens from specific collections may nest tokens under this
SourceCollectionIsNotAllowedToNest,
+
+ /// Tried to store more data than allowed in collection field
+ CollectionFieldSizeExceeded,
}
#[pallet::storage]
@@ -369,6 +372,17 @@
QueryKind = OptionQuery,
>;
+ /// Large variable-size collection fields are extracted here
+ #[pallet::storage]
+ pub type CollectionData<T> = StorageNMap<
+ Key = (
+ Key<Twox64Concat, CollectionId>,
+ Key<Twox64Concat, CollectionField>,
+ ),
+ Value = BoundedVec<u8, ConstU32<COLLECTION_FIELD_LIMIT>>,
+ QueryKind = ValueQuery,
+ >;
+
#[pallet::storage]
pub type AdminAmount<T> = StorageMap<
Hasher = Blake2_128Concat,
@@ -409,7 +423,26 @@
fn on_runtime_upgrade() -> Weight {
if StorageVersion::get::<Pallet<T>>() < StorageVersion::new(1) {
use up_data_structs::{CollectionVersion1, CollectionVersion2};
- <CollectionById<T>>::translate_values::<CollectionVersion1<T::AccountId>, _>(|v| {
+ <CollectionById<T>>::translate::<CollectionVersion1<T::AccountId>, _>(|id, v| {
+ Self::set_field_raw(
+ id,
+ CollectionField::OffchainSchema,
+ v.offchain_schema.clone().into_inner(),
+ )
+ .expect("data has lower bounds than field");
+ Self::set_field_raw(
+ id,
+ CollectionField::VariableOnChainSchema,
+ v.variable_on_chain_schema.clone().into_inner(),
+ )
+ .expect("data has lower bounds than field");
+ Self::set_field_raw(
+ id,
+ CollectionField::ConstOnChainSchema,
+ v.const_on_chain_schema.clone().into_inner(),
+ )
+ .expect("data has lower bounds than field");
+
Some(CollectionVersion2::from(v))
});
}
@@ -483,6 +516,50 @@
Some(effective_limits)
}
+
+ pub fn rpc_collection(collection: CollectionId) -> Option<RpcCollection<T::AccountId>> {
+ let Collection {
+ name,
+ description,
+ owner,
+ mode,
+ access,
+ token_prefix,
+ mint_mode,
+ schema_version,
+ sponsorship,
+ limits,
+ meta_update_permission,
+ } = <CollectionById<T>>::get(collection)?;
+ Some(RpcCollection {
+ name: name.into_inner(),
+ description: description.into_inner(),
+ owner,
+ mode,
+ access,
+ token_prefix: token_prefix.into_inner(),
+ mint_mode,
+ schema_version,
+ sponsorship,
+ limits,
+ meta_update_permission,
+ offchain_schema: <CollectionData<T>>::get((
+ collection,
+ CollectionField::OffchainSchema,
+ ))
+ .into_inner(),
+ const_on_chain_schema: <CollectionData<T>>::get((
+ collection,
+ CollectionField::ConstOnChainSchema,
+ ))
+ .into_inner(),
+ variable_on_chain_schema: <CollectionData<T>>::get((
+ collection,
+ CollectionField::VariableOnChainSchema,
+ ))
+ .into_inner(),
+ })
+ }
}
impl<T: Config> Pallet<T> {
@@ -520,14 +597,11 @@
access: data.access.unwrap_or_default(),
description: data.description,
token_prefix: data.token_prefix,
- offchain_schema: data.offchain_schema,
schema_version: data.schema_version.unwrap_or_default(),
sponsorship: data
.pending_sponsor
.map(SponsorshipState::Unconfirmed)
.unwrap_or_default(),
- variable_on_chain_schema: data.variable_on_chain_schema,
- const_on_chain_schema: data.const_on_chain_schema,
limits: data
.limits
.map(|limits| Self::clamp_limits(data.mode.clone(), &Default::default(), limits))
@@ -557,6 +631,24 @@
<CreatedCollectionCount<T>>::put(created_count);
<Pallet<T>>::deposit_event(Event::CollectionCreated(id, data.mode.id(), owner.clone()));
<CollectionById<T>>::insert(id, collection);
+ Self::set_field_raw(
+ id,
+ CollectionField::OffchainSchema,
+ data.offchain_schema.into_inner(),
+ )
+ .expect("data has lower bounds than field");
+ Self::set_field_raw(
+ id,
+ CollectionField::VariableOnChainSchema,
+ data.variable_on_chain_schema.into_inner(),
+ )
+ .expect("data has lower bounds than field");
+ Self::set_field_raw(
+ id,
+ CollectionField::ConstOnChainSchema,
+ data.const_on_chain_schema.into_inner(),
+ )
+ .expect("data has lower bounds than field");
Ok(id)
}
@@ -579,6 +671,7 @@
<DestroyedCollectionCount<T>>::put(destroyed_collections);
<CollectionById<T>>::remove(collection.id);
+ <CollectionData<T>>::remove_prefix((collection.id,), None);
<AdminAmount<T>>::remove(collection.id);
<IsAdmin<T>>::remove_prefix((collection.id,), None);
<Allowlist<T>>::remove_prefix((collection.id,), None);
@@ -587,6 +680,35 @@
Ok(())
}
+ fn set_field_raw(
+ collection_id: CollectionId,
+ field: CollectionField,
+ value: Vec<u8>,
+ ) -> DispatchResult {
+ if !value.is_empty() {
+ <CollectionData<T>>::insert(
+ (collection_id, field),
+ BoundedVec::try_from(value).map_err(|_| <Error<T>>::CollectionFieldSizeExceeded)?,
+ )
+ } else {
+ <CollectionData<T>>::remove((collection_id, field));
+ }
+ Ok(())
+ }
+
+ pub fn set_field(
+ collection: &CollectionHandle<T>,
+ sender: &T::CrossAccountId,
+ field: CollectionField,
+ value: Vec<u8>,
+ ) -> DispatchResult {
+ collection.check_is_owner_or_admin(sender)?;
+
+ // =========
+
+ Self::set_field_raw(collection.id, field, value)
+ }
+
pub fn toggle_allowlist(
collection: &CollectionHandle<T>,
sender: &T::CrossAccountId,
pallets/unique/src/lib.rsdiffbeforeafterboth--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -43,7 +43,7 @@
MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,
AccessMode, CreateItemData, CollectionLimits, CollectionId, CollectionMode, TokenId,
SchemaVersion, SponsorshipState, MetaUpdatePermission, CreateCollectionData, CustomDataLimit,
- CreateItemExData, budget,
+ CreateItemExData, budget, CollectionField,
};
use pallet_evm::account::CrossAccountId;
use pallet_common::{
@@ -1004,16 +1004,16 @@
schema: BoundedVec<u8, ConstU32<OFFCHAIN_SCHEMA_LIMIT>>,
) -> DispatchResult {
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;
- target_collection.check_is_owner_or_admin(&sender)?;
+ let collection = <CollectionHandle<T>>::try_get(collection_id)?;
+
+ // =========
- target_collection.offchain_schema = schema;
+ <PalletCommon<T>>::set_field(&collection, &sender, CollectionField::OffchainSchema, schema.into_inner())?;
<Pallet<T>>::deposit_event(Event::<T>::OffchainSchemaSet(
collection_id
));
-
- target_collection.save()
+ Ok(())
}
/// Set const on-chain data schema.
@@ -1036,16 +1036,16 @@
schema: BoundedVec<u8, ConstU32<CONST_ON_CHAIN_SCHEMA_LIMIT>>
) -> DispatchResult {
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;
- target_collection.check_is_owner_or_admin(&sender)?;
+ let collection = <CollectionHandle<T>>::try_get(collection_id)?;
+
+ // =========
- target_collection.const_on_chain_schema = schema;
+ <PalletCommon<T>>::set_field(&collection, &sender, CollectionField::ConstOnChainSchema, schema.into_inner())?;
<Pallet<T>>::deposit_event(Event::<T>::ConstOnChainSchemaSet(
collection_id
));
-
- target_collection.save()
+ Ok(())
}
/// Set variable on-chain data schema.
@@ -1068,16 +1068,16 @@
schema: BoundedVec<u8, ConstU32<VARIABLE_ON_CHAIN_SCHEMA_LIMIT>>
) -> DispatchResult {
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;
- target_collection.check_is_owner_or_admin(&sender)?;
+ let collection = <CollectionHandle<T>>::try_get(collection_id)?;
+
+ // =========
- target_collection.variable_on_chain_schema = schema;
+ <PalletCommon<T>>::set_field(&collection, &sender, CollectionField::VariableOnChainSchema, schema.into_inner())?;
<Pallet<T>>::deposit_event(Event::<T>::VariableOnChainSchemaSet(
collection_id
));
-
- target_collection.save()
+ Ok(())
}
#[weight = <SelfWeightOf<T>>::set_collection_limits()]
primitives/data-structs/src/lib.rsdiffbeforeafterboth--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -78,6 +78,9 @@
pub const VARIABLE_ON_CHAIN_SCHEMA_LIMIT: u32 = 8192;
pub const CONST_ON_CHAIN_SCHEMA_LIMIT: u32 = 32768;
+pub const COLLECTION_FIELD_LIMIT: u32 = CONST_ON_CHAIN_SCHEMA_LIMIT;
+// u32::max is not const: OFFCHAIN_SCHEMA_LIMIT.max(VARIABLE_ON_CHAIN_SCHEMA_LIMIT).max(CONST_ON_CHAIN_SCHEMA_LIMIT);
+
pub const MAX_COLLECTION_NAME_LENGTH: u32 = 64;
pub const MAX_COLLECTION_DESCRIPTION_LENGTH: u32 = 256;
pub const MAX_TOKEN_PREFIX_LENGTH: u32 = 16;
@@ -248,22 +251,21 @@
}
}
+/// Used in storage
#[struct_versioning::versioned(version = 2, upper)]
#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen)]
-#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub struct Collection<AccountId> {
pub owner: AccountId,
pub mode: CollectionMode,
pub access: AccessMode,
- #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]
pub name: BoundedVec<u16, ConstU32<MAX_COLLECTION_NAME_LENGTH>>,
- #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]
pub description: BoundedVec<u16, ConstU32<MAX_COLLECTION_DESCRIPTION_LENGTH>>,
- #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]
pub token_prefix: BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>,
pub mint_mode: bool,
- #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]
+
+ #[version(..2)]
pub offchain_schema: BoundedVec<u8, ConstU32<OFFCHAIN_SCHEMA_LIMIT>>,
+
pub schema_version: SchemaVersion,
pub sponsorship: SponsorshipState<AccountId>,
@@ -272,13 +274,42 @@
#[version(2.., upper(limits.into()))]
pub limits: CollectionLimitsVersion2,
- #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]
+ #[version(..2)]
pub variable_on_chain_schema: BoundedVec<u8, ConstU32<VARIABLE_ON_CHAIN_SCHEMA_LIMIT>>,
- #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]
+ #[version(..2)]
pub const_on_chain_schema: BoundedVec<u8, ConstU32<CONST_ON_CHAIN_SCHEMA_LIMIT>>,
+
pub meta_update_permission: MetaUpdatePermission,
}
+/// Used in RPC calls
+#[derive(Encode, Decode, Clone, PartialEq, TypeInfo)]
+#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
+pub struct RpcCollection<AccountId> {
+ pub owner: AccountId,
+ pub mode: CollectionMode,
+ pub access: AccessMode,
+ pub name: Vec<u16>,
+ pub description: Vec<u16>,
+ pub token_prefix: Vec<u8>,
+ pub mint_mode: bool,
+ pub offchain_schema: Vec<u8>,
+ pub schema_version: SchemaVersion,
+ pub sponsorship: SponsorshipState<AccountId>,
+ pub limits: CollectionLimits,
+ pub variable_on_chain_schema: Vec<u8>,
+ pub const_on_chain_schema: Vec<u8>,
+ pub meta_update_permission: MetaUpdatePermission,
+}
+
+#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen)]
+#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
+pub enum CollectionField {
+ VariableOnChainSchema,
+ ConstOnChainSchema,
+ OffchainSchema,
+}
+
#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, Debug, Derivative, MaxEncodedLen)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
#[derivative(Default(bound = ""))]
primitives/rpc/src/lib.rsdiffbeforeafterboth--- a/primitives/rpc/src/lib.rs
+++ b/primitives/rpc/src/lib.rs
@@ -16,7 +16,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
-use up_data_structs::{CollectionId, TokenId, Collection, CollectionStats, CollectionLimits};
+use up_data_structs::{CollectionId, TokenId, RpcCollection, Collection, CollectionStats, CollectionLimits};
use sp_std::vec::Vec;
use codec::Decode;
use sp_runtime::DispatchError;
@@ -53,7 +53,7 @@
fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;
fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool>;
fn last_token_id(collection: CollectionId) -> Result<TokenId>;
- fn collection_by_id(collection: CollectionId) -> Result<Option<Collection<AccountId>>>;
+ fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>>;
fn collection_stats() -> Result<CollectionStats>;
fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>>;
fn effective_collection_limits(collection_id: CollectionId) -> Result<Option<CollectionLimits>>;
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 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 token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {18 dispatch_unique_runtime!(collection.token_exists(token))19 }2021 fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {22 dispatch_unique_runtime!(collection.token_owner(token))23 }24 fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {25 dispatch_unique_runtime!(collection.const_metadata(token))26 }27 fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {28 dispatch_unique_runtime!(collection.variable_metadata(token))29 }3031 fn collection_tokens(collection: CollectionId) -> Result<u32, DispatchError> {32 dispatch_unique_runtime!(collection.collection_tokens())33 }34 fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {35 dispatch_unique_runtime!(collection.account_balance(account))36 }37 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {38 dispatch_unique_runtime!(collection.balance(account, token))39 }40 fn allowance(41 collection: CollectionId,42 sender: CrossAccountId,43 spender: CrossAccountId,44 token: TokenId,45 ) -> Result<u128, DispatchError> {46 dispatch_unique_runtime!(collection.allowance(sender, spender, token))47 }4849 fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {50 Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))51 }52 fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {53 Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))54 }55 fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {56 Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))57 }58 fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {59 dispatch_unique_runtime!(collection.last_token_id())60 }61 fn collection_by_id(collection: CollectionId) -> Result<Option<Collection<AccountId>>, DispatchError> {62 Ok(<pallet_common::CollectionById<Runtime>>::get(collection))63 }64 fn collection_stats() -> Result<CollectionStats, DispatchError> {65 Ok(<pallet_common::Pallet<Runtime>>::collection_stats())66 }67 fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>, DispatchError> {68 Ok(<pallet_unique::UniqueSponsorshipPredict<Runtime> as69 pallet_unique::SponsorshipPredict<Runtime>>::predict(70 collection,71 account,72 token))73 }7475 fn effective_collection_limits(collection: CollectionId) -> Result<Option<CollectionLimits>, DispatchError> {76 Ok(<pallet_common::Pallet<Runtime>>::effective_collection_limits(collection))77 }78 }7980 impl sp_api::Core<Block> for Runtime {81 fn version() -> RuntimeVersion {82 VERSION83 }8485 fn execute_block(block: Block) {86 Executive::execute_block(block)87 }8889 fn initialize_block(header: &<Block as BlockT>::Header) {90 Executive::initialize_block(header)91 }92 }9394 impl sp_api::Metadata<Block> for Runtime {95 fn metadata() -> OpaqueMetadata {96 OpaqueMetadata::new(Runtime::metadata().into())97 }98 }99100 impl sp_block_builder::BlockBuilder<Block> for Runtime {101 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {102 Executive::apply_extrinsic(extrinsic)103 }104105 fn finalize_block() -> <Block as BlockT>::Header {106 Executive::finalize_block()107 }108109 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {110 data.create_extrinsics()111 }112113 fn check_inherents(114 block: Block,115 data: sp_inherents::InherentData,116 ) -> sp_inherents::CheckInherentsResult {117 data.check_extrinsics(&block)118 }119120 // fn random_seed() -> <Block as BlockT>::Hash {121 // RandomnessCollectiveFlip::random_seed().0122 // }123 }124125 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {126 fn validate_transaction(127 source: TransactionSource,128 tx: <Block as BlockT>::Extrinsic,129 hash: <Block as BlockT>::Hash,130 ) -> TransactionValidity {131 Executive::validate_transaction(source, tx, hash)132 }133 }134135 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {136 fn offchain_worker(header: &<Block as BlockT>::Header) {137 Executive::offchain_worker(header)138 }139 }140141 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {142 fn chain_id() -> u64 {143 <Runtime as pallet_evm::Config>::ChainId::get()144 }145146 fn account_basic(address: H160) -> EVMAccount {147 EVM::account_basic(&address)148 }149150 fn gas_price() -> U256 {151 <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()152 }153154 fn account_code_at(address: H160) -> Vec<u8> {155 EVM::account_codes(address)156 }157158 fn author() -> H160 {159 <pallet_evm::Pallet<Runtime>>::find_author()160 }161162 fn storage_at(address: H160, index: U256) -> H256 {163 let mut tmp = [0u8; 32];164 index.to_big_endian(&mut tmp);165 EVM::account_storages(address, H256::from_slice(&tmp[..]))166 }167168 #[allow(clippy::redundant_closure)]169 fn call(170 from: H160,171 to: H160,172 data: Vec<u8>,173 value: U256,174 gas_limit: U256,175 max_fee_per_gas: Option<U256>,176 max_priority_fee_per_gas: Option<U256>,177 nonce: Option<U256>,178 estimate: bool,179 access_list: Option<Vec<(H160, Vec<H256>)>>,180 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {181 let config = if estimate {182 let mut config = <Runtime as pallet_evm::Config>::config().clone();183 config.estimate = true;184 Some(config)185 } else {186 None187 };188189 let is_transactional = false;190 <Runtime as pallet_evm::Config>::Runner::call(191 CrossAccountId::from_eth(from),192 to,193 data,194 value,195 gas_limit.low_u64(),196 max_fee_per_gas,197 max_priority_fee_per_gas,198 nonce,199 access_list.unwrap_or_default(),200 is_transactional,201 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),202 ).map_err(|err| err.into())203 }204205 #[allow(clippy::redundant_closure)]206 fn create(207 from: H160,208 data: Vec<u8>,209 value: U256,210 gas_limit: U256,211 max_fee_per_gas: Option<U256>,212 max_priority_fee_per_gas: Option<U256>,213 nonce: Option<U256>,214 estimate: bool,215 access_list: Option<Vec<(H160, Vec<H256>)>>,216 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {217 let config = if estimate {218 let mut config = <Runtime as pallet_evm::Config>::config().clone();219 config.estimate = true;220 Some(config)221 } else {222 None223 };224225 let is_transactional = false;226 <Runtime as pallet_evm::Config>::Runner::create(227 CrossAccountId::from_eth(from),228 data,229 value,230 gas_limit.low_u64(),231 max_fee_per_gas,232 max_priority_fee_per_gas,233 nonce,234 access_list.unwrap_or_default(),235 is_transactional,236 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),237 ).map_err(|err| err.into())238 }239240 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {241 Ethereum::current_transaction_statuses()242 }243244 fn current_block() -> Option<pallet_ethereum::Block> {245 Ethereum::current_block()246 }247248 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {249 Ethereum::current_receipts()250 }251252 fn current_all() -> (253 Option<pallet_ethereum::Block>,254 Option<Vec<pallet_ethereum::Receipt>>,255 Option<Vec<TransactionStatus>>256 ) {257 (258 Ethereum::current_block(),259 Ethereum::current_receipts(),260 Ethereum::current_transaction_statuses()261 )262 }263264 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {265 xts.into_iter().filter_map(|xt| match xt.0.function {266 Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),267 _ => None268 }).collect()269 }270271 fn elasticity() -> Option<Permill> {272 None273 }274 }275276 impl fp_rpc::ConvertTransactionRuntimeApi<Block> for Runtime {277 fn convert_transaction(transaction: pallet_ethereum::Transaction) -> <Block as BlockT>::Extrinsic {278 UncheckedExtrinsic::new_unsigned(279 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),280 )281 }282 }283284 impl sp_session::SessionKeys<Block> for Runtime {285 fn decode_session_keys(286 encoded: Vec<u8>,287 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {288 SessionKeys::decode_into_raw_public_keys(&encoded)289 }290291 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {292 SessionKeys::generate(seed)293 }294 }295296 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {297 fn slot_duration() -> sp_consensus_aura::SlotDuration {298 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())299 }300301 fn authorities() -> Vec<AuraId> {302 Aura::authorities().to_vec()303 }304 }305306 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {307 fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {308 ParachainSystem::collect_collation_info(header)309 }310 }311312 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {313 fn account_nonce(account: AccountId) -> Index {314 System::account_nonce(account)315 }316 }317318 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {319 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {320 TransactionPayment::query_info(uxt, len)321 }322 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {323 TransactionPayment::query_fee_details(uxt, len)324 }325 }326327 /*328 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>329 for Runtime330 {331 fn call(332 origin: AccountId,333 dest: AccountId,334 value: Balance,335 gas_limit: u64,336 input_data: Vec<u8>,337 ) -> pallet_contracts_primitives::ContractExecResult {338 Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)339 }340341 fn instantiate(342 origin: AccountId,343 endowment: Balance,344 gas_limit: u64,345 code: pallet_contracts_primitives::Code<Hash>,346 data: Vec<u8>,347 salt: Vec<u8>,348 ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>349 {350 Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)351 }352353 fn get_storage(354 address: AccountId,355 key: [u8; 32],356 ) -> pallet_contracts_primitives::GetStorageResult {357 Contracts::get_storage(address, key)358 }359360 fn rent_projection(361 address: AccountId,362 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {363 Contracts::rent_projection(address)364 }365 }366 */367368 #[cfg(feature = "runtime-benchmarks")]369 impl frame_benchmarking::Benchmark<Block> for Runtime {370 fn benchmark_metadata(extra: bool) -> (371 Vec<frame_benchmarking::BenchmarkList>,372 Vec<frame_support::traits::StorageInfo>,373 ) {374 use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};375 use frame_support::traits::StorageInfoTrait;376377 let mut list = Vec::<BenchmarkList>::new();378379 list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);380 list_benchmark!(list, extra, pallet_unique, Unique);381 list_benchmark!(list, extra, pallet_structure, Structure);382 list_benchmark!(list, extra, pallet_inflation, Inflation);383 list_benchmark!(list, extra, pallet_fungible, Fungible);384 list_benchmark!(list, extra, pallet_refungible, Refungible);385 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);386 // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);387388 let storage_info = AllPalletsReversedWithSystemFirst::storage_info();389390 return (list, storage_info)391 }392393 fn dispatch_benchmark(394 config: frame_benchmarking::BenchmarkConfig395 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {396 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};397398 let allowlist: Vec<TrackedStorageKey> = vec![399 // Block Number400 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),401 // Total Issuance402 hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),403 // Execution Phase404 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),405 // Event Count406 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),407 // System Events408 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),409410 // Transactional depth411 hex_literal::hex!("3a7472616e73616374696f6e5f6c6576656c3a").to_vec().into(),412 ];413414 let mut batches = Vec::<BenchmarkBatch>::new();415 let params = (&config, &allowlist);416417 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);418 add_benchmark!(params, batches, pallet_unique, Unique);419 add_benchmark!(params, batches, pallet_structure, Structure);420 add_benchmark!(params, batches, pallet_inflation, Inflation);421 add_benchmark!(params, batches, pallet_fungible, Fungible);422 add_benchmark!(params, batches, pallet_refungible, Refungible);423 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);424 // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);425426 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }427 Ok(batches)428 }429 }430431 #[cfg(feature = "try-runtime")]432 impl frame_try_runtime::TryRuntime<Block> for Runtime {433 fn on_runtime_upgrade() -> (Weight, Weight) {434 log::info!("try-runtime::on_runtime_upgrade unique-chain.");435 let weight = Executive::try_runtime_upgrade().unwrap();436 (weight, RuntimeBlockWeights::get().max_block)437 }438439 fn execute_block_no_check(block: Block) -> Weight {440 Executive::execute_block_no_check(block)441 }442 }443 }444 }445}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 token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {18 dispatch_unique_runtime!(collection.token_exists(token))19 }2021 fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {22 dispatch_unique_runtime!(collection.token_owner(token))23 }24 fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {25 dispatch_unique_runtime!(collection.const_metadata(token))26 }27 fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {28 dispatch_unique_runtime!(collection.variable_metadata(token))29 }3031 fn collection_tokens(collection: CollectionId) -> Result<u32, DispatchError> {32 dispatch_unique_runtime!(collection.collection_tokens())33 }34 fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {35 dispatch_unique_runtime!(collection.account_balance(account))36 }37 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {38 dispatch_unique_runtime!(collection.balance(account, token))39 }40 fn allowance(41 collection: CollectionId,42 sender: CrossAccountId,43 spender: CrossAccountId,44 token: TokenId,45 ) -> Result<u128, DispatchError> {46 dispatch_unique_runtime!(collection.allowance(sender, spender, token))47 }4849 fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {50 Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))51 }52 fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {53 Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))54 }55 fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {56 Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))57 }58 fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {59 dispatch_unique_runtime!(collection.last_token_id())60 }61 fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>, DispatchError> {62 Ok(<pallet_common::Pallet<Runtime>>::rpc_collection(collection))63 }64 fn collection_stats() -> Result<CollectionStats, DispatchError> {65 Ok(<pallet_common::Pallet<Runtime>>::collection_stats())66 }67 fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>, DispatchError> {68 Ok(<pallet_unique::UniqueSponsorshipPredict<Runtime> as69 pallet_unique::SponsorshipPredict<Runtime>>::predict(70 collection,71 account,72 token))73 }7475 fn effective_collection_limits(collection: CollectionId) -> Result<Option<CollectionLimits>, DispatchError> {76 Ok(<pallet_common::Pallet<Runtime>>::effective_collection_limits(collection))77 }78 }7980 impl sp_api::Core<Block> for Runtime {81 fn version() -> RuntimeVersion {82 VERSION83 }8485 fn execute_block(block: Block) {86 Executive::execute_block(block)87 }8889 fn initialize_block(header: &<Block as BlockT>::Header) {90 Executive::initialize_block(header)91 }92 }9394 impl sp_api::Metadata<Block> for Runtime {95 fn metadata() -> OpaqueMetadata {96 OpaqueMetadata::new(Runtime::metadata().into())97 }98 }99100 impl sp_block_builder::BlockBuilder<Block> for Runtime {101 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {102 Executive::apply_extrinsic(extrinsic)103 }104105 fn finalize_block() -> <Block as BlockT>::Header {106 Executive::finalize_block()107 }108109 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {110 data.create_extrinsics()111 }112113 fn check_inherents(114 block: Block,115 data: sp_inherents::InherentData,116 ) -> sp_inherents::CheckInherentsResult {117 data.check_extrinsics(&block)118 }119120 // fn random_seed() -> <Block as BlockT>::Hash {121 // RandomnessCollectiveFlip::random_seed().0122 // }123 }124125 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {126 fn validate_transaction(127 source: TransactionSource,128 tx: <Block as BlockT>::Extrinsic,129 hash: <Block as BlockT>::Hash,130 ) -> TransactionValidity {131 Executive::validate_transaction(source, tx, hash)132 }133 }134135 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {136 fn offchain_worker(header: &<Block as BlockT>::Header) {137 Executive::offchain_worker(header)138 }139 }140141 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {142 fn chain_id() -> u64 {143 <Runtime as pallet_evm::Config>::ChainId::get()144 }145146 fn account_basic(address: H160) -> EVMAccount {147 EVM::account_basic(&address)148 }149150 fn gas_price() -> U256 {151 <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()152 }153154 fn account_code_at(address: H160) -> Vec<u8> {155 EVM::account_codes(address)156 }157158 fn author() -> H160 {159 <pallet_evm::Pallet<Runtime>>::find_author()160 }161162 fn storage_at(address: H160, index: U256) -> H256 {163 let mut tmp = [0u8; 32];164 index.to_big_endian(&mut tmp);165 EVM::account_storages(address, H256::from_slice(&tmp[..]))166 }167168 #[allow(clippy::redundant_closure)]169 fn call(170 from: H160,171 to: H160,172 data: Vec<u8>,173 value: U256,174 gas_limit: U256,175 max_fee_per_gas: Option<U256>,176 max_priority_fee_per_gas: Option<U256>,177 nonce: Option<U256>,178 estimate: bool,179 access_list: Option<Vec<(H160, Vec<H256>)>>,180 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {181 let config = if estimate {182 let mut config = <Runtime as pallet_evm::Config>::config().clone();183 config.estimate = true;184 Some(config)185 } else {186 None187 };188189 let is_transactional = false;190 <Runtime as pallet_evm::Config>::Runner::call(191 CrossAccountId::from_eth(from),192 to,193 data,194 value,195 gas_limit.low_u64(),196 max_fee_per_gas,197 max_priority_fee_per_gas,198 nonce,199 access_list.unwrap_or_default(),200 is_transactional,201 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),202 ).map_err(|err| err.into())203 }204205 #[allow(clippy::redundant_closure)]206 fn create(207 from: H160,208 data: Vec<u8>,209 value: U256,210 gas_limit: U256,211 max_fee_per_gas: Option<U256>,212 max_priority_fee_per_gas: Option<U256>,213 nonce: Option<U256>,214 estimate: bool,215 access_list: Option<Vec<(H160, Vec<H256>)>>,216 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {217 let config = if estimate {218 let mut config = <Runtime as pallet_evm::Config>::config().clone();219 config.estimate = true;220 Some(config)221 } else {222 None223 };224225 let is_transactional = false;226 <Runtime as pallet_evm::Config>::Runner::create(227 CrossAccountId::from_eth(from),228 data,229 value,230 gas_limit.low_u64(),231 max_fee_per_gas,232 max_priority_fee_per_gas,233 nonce,234 access_list.unwrap_or_default(),235 is_transactional,236 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),237 ).map_err(|err| err.into())238 }239240 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {241 Ethereum::current_transaction_statuses()242 }243244 fn current_block() -> Option<pallet_ethereum::Block> {245 Ethereum::current_block()246 }247248 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {249 Ethereum::current_receipts()250 }251252 fn current_all() -> (253 Option<pallet_ethereum::Block>,254 Option<Vec<pallet_ethereum::Receipt>>,255 Option<Vec<TransactionStatus>>256 ) {257 (258 Ethereum::current_block(),259 Ethereum::current_receipts(),260 Ethereum::current_transaction_statuses()261 )262 }263264 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {265 xts.into_iter().filter_map(|xt| match xt.0.function {266 Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),267 _ => None268 }).collect()269 }270271 fn elasticity() -> Option<Permill> {272 None273 }274 }275276 impl fp_rpc::ConvertTransactionRuntimeApi<Block> for Runtime {277 fn convert_transaction(transaction: pallet_ethereum::Transaction) -> <Block as BlockT>::Extrinsic {278 UncheckedExtrinsic::new_unsigned(279 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),280 )281 }282 }283284 impl sp_session::SessionKeys<Block> for Runtime {285 fn decode_session_keys(286 encoded: Vec<u8>,287 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {288 SessionKeys::decode_into_raw_public_keys(&encoded)289 }290291 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {292 SessionKeys::generate(seed)293 }294 }295296 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {297 fn slot_duration() -> sp_consensus_aura::SlotDuration {298 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())299 }300301 fn authorities() -> Vec<AuraId> {302 Aura::authorities().to_vec()303 }304 }305306 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {307 fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {308 ParachainSystem::collect_collation_info(header)309 }310 }311312 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {313 fn account_nonce(account: AccountId) -> Index {314 System::account_nonce(account)315 }316 }317318 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {319 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {320 TransactionPayment::query_info(uxt, len)321 }322 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {323 TransactionPayment::query_fee_details(uxt, len)324 }325 }326327 /*328 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>329 for Runtime330 {331 fn call(332 origin: AccountId,333 dest: AccountId,334 value: Balance,335 gas_limit: u64,336 input_data: Vec<u8>,337 ) -> pallet_contracts_primitives::ContractExecResult {338 Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)339 }340341 fn instantiate(342 origin: AccountId,343 endowment: Balance,344 gas_limit: u64,345 code: pallet_contracts_primitives::Code<Hash>,346 data: Vec<u8>,347 salt: Vec<u8>,348 ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>349 {350 Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)351 }352353 fn get_storage(354 address: AccountId,355 key: [u8; 32],356 ) -> pallet_contracts_primitives::GetStorageResult {357 Contracts::get_storage(address, key)358 }359360 fn rent_projection(361 address: AccountId,362 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {363 Contracts::rent_projection(address)364 }365 }366 */367368 #[cfg(feature = "runtime-benchmarks")]369 impl frame_benchmarking::Benchmark<Block> for Runtime {370 fn benchmark_metadata(extra: bool) -> (371 Vec<frame_benchmarking::BenchmarkList>,372 Vec<frame_support::traits::StorageInfo>,373 ) {374 use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};375 use frame_support::traits::StorageInfoTrait;376377 let mut list = Vec::<BenchmarkList>::new();378379 list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);380 list_benchmark!(list, extra, pallet_unique, Unique);381 list_benchmark!(list, extra, pallet_structure, Structure);382 list_benchmark!(list, extra, pallet_inflation, Inflation);383 list_benchmark!(list, extra, pallet_fungible, Fungible);384 list_benchmark!(list, extra, pallet_refungible, Refungible);385 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);386 // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);387388 let storage_info = AllPalletsReversedWithSystemFirst::storage_info();389390 return (list, storage_info)391 }392393 fn dispatch_benchmark(394 config: frame_benchmarking::BenchmarkConfig395 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {396 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};397398 let allowlist: Vec<TrackedStorageKey> = vec![399 // Block Number400 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),401 // Total Issuance402 hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),403 // Execution Phase404 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),405 // Event Count406 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),407 // System Events408 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),409410 // Transactional depth411 hex_literal::hex!("3a7472616e73616374696f6e5f6c6576656c3a").to_vec().into(),412 ];413414 let mut batches = Vec::<BenchmarkBatch>::new();415 let params = (&config, &allowlist);416417 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);418 add_benchmark!(params, batches, pallet_unique, Unique);419 add_benchmark!(params, batches, pallet_structure, Structure);420 add_benchmark!(params, batches, pallet_inflation, Inflation);421 add_benchmark!(params, batches, pallet_fungible, Fungible);422 add_benchmark!(params, batches, pallet_refungible, Refungible);423 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);424 // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);425426 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }427 Ok(batches)428 }429 }430431 #[cfg(feature = "try-runtime")]432 impl frame_try_runtime::TryRuntime<Block> for Runtime {433 fn on_runtime_upgrade() -> (Weight, Weight) {434 log::info!("try-runtime::on_runtime_upgrade unique-chain.");435 let weight = Executive::try_runtime_upgrade().unwrap();436 (weight, RuntimeBlockWeights::get().max_block)437 }438439 fn execute_block_no_check(block: Block) -> Weight {440 Executive::execute_block_no_check(block)441 }442 }443 }444 }445}runtime/opal/src/lib.rsdiffbeforeafterboth--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -67,7 +67,7 @@
},
};
use up_data_structs::mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping};
-use up_data_structs::{CollectionId, TokenId, CollectionStats, Collection};
+use up_data_structs::{CollectionId, TokenId, CollectionStats, Collection, RpcCollection};
// use pallet_contracts::weights::WeightInfo;
// #[cfg(any(feature = "std", test))]
use frame_system::{