difftreelog
CORE-238 add effective_collection_limits
in: master
13 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -9360,6 +9360,42 @@
]
[[package]]
+name = "sc-consensus-manual-seal"
+version = "0.10.0-dev"
+source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.17#22d40c761a985482f93bbbea5ba4199bdba74f8e"
+dependencies = [
+ "assert_matches",
+ "async-trait",
+ "futures 0.3.21",
+ "jsonrpc-core",
+ "jsonrpc-core-client",
+ "jsonrpc-derive",
+ "log",
+ "parity-scale-codec",
+ "sc-client-api",
+ "sc-consensus",
+ "sc-consensus-aura",
+ "sc-consensus-babe",
+ "sc-consensus-epochs",
+ "sc-transaction-pool",
+ "sc-transaction-pool-api",
+ "serde",
+ "sp-api",
+ "sp-blockchain",
+ "sp-consensus",
+ "sp-consensus-aura",
+ "sp-consensus-babe",
+ "sp-consensus-slots",
+ "sp-core",
+ "sp-inherents",
+ "sp-keystore",
+ "sp-runtime",
+ "sp-timestamp",
+ "substrate-prometheus-endpoint",
+ "thiserror",
+]
+
+[[package]]
name = "sc-consensus-slots"
version = "0.10.0-dev"
source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.17#22d40c761a985482f93bbbea5ba4199bdba74f8e"
@@ -11697,7 +11733,7 @@
"chrono",
"lazy_static",
"matchers",
- "parking_lot 0.11.2",
+ "parking_lot 0.10.2",
"regex",
"serde",
"serde_json",
@@ -11957,6 +11993,7 @@
"sc-client-api",
"sc-consensus",
"sc-consensus-aura",
+ "sc-consensus-manual-seal",
"sc-executor",
"sc-finality-grandpa",
"sc-keystore",
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, TokenId};
+use up_data_structs::{Collection, CollectionId, CollectionStats, CollectionLimits, TokenId};
use sp_api::{BlockId, BlockT, ProvideRuntimeApi, ApiExt};
use sp_blockchain::HeaderBackend;
use up_rpc::UniqueApi as UniqueRuntimeApi;
@@ -119,6 +119,12 @@
) -> Result<Option<Collection<AccountId>>>;
#[rpc(name = "unique_collectionStats")]
fn collection_stats(&self, at: Option<BlockHash>) -> Result<CollectionStats>;
+ #[rpc(name = "unique_effectiveCollectionLimits")]
+ fn effective_collection_limits(
+ &self,
+ collection_id: CollectionId,
+ at: Option<BlockHash>
+ ) -> Result<Option<CollectionLimits>>;
}
pub struct Unique<C, P> {
@@ -222,4 +228,5 @@
pass_method!(last_token_id(collection: CollectionId) -> TokenId);
pass_method!(collection_by_id(collection: CollectionId) -> Option<Collection<AccountId>>);
pass_method!(collection_stats() -> CollectionStats);
+ 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
@@ -33,7 +33,7 @@
TokenId, Weight, WithdrawReasons, 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,
+ CustomDataLimit, CreateCollectionData, SponsorshipState, CreateItemExData, SponsoringRateLimit
};
pub use pallet::*;
use sp_core::H160;
@@ -421,6 +421,30 @@
alive: created.0 - destroyed.0,
}
}
+
+ pub fn effective_collection_limits(collection: CollectionId) -> Option<CollectionLimits> {
+ let collection = <CollectionById<T>>::get(collection);
+ if collection.is_none() {
+ return None;
+ }
+
+ let limits = collection.unwrap().limits;
+ let effective_limits = CollectionLimits {
+ account_token_ownership_limit: Some(limits.account_token_ownership_limit()),
+ sponsored_data_size: Some(limits.sponsored_data_size()),
+ sponsored_data_rate_limit: Some(
+ limits.sponsored_data_rate_limit
+ .unwrap_or(SponsoringRateLimit::SponsoringDisabled)),
+ token_limit: Some(limits.token_limit()),
+ sponsor_transfer_timeout: Some(limits.sponsor_transfer_timeout(MAX_SPONSOR_TIMEOUT)),
+ sponsor_approve_timeout: Some(limits.sponsor_approve_timeout()),
+ owner_can_transfer: Some(limits.owner_can_transfer()),
+ owner_can_destroy: Some(limits.owner_can_destroy()),
+ transfers_enabled: Some(limits.transfers_enabled()),
+ };
+
+ Some(effective_limits)
+ }
}
impl<T: Config> Pallet<T> {
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};
+use up_data_structs::{CollectionId, TokenId, Collection, CollectionStats, CollectionLimits};
use sp_std::vec::Vec;
use sp_core::H160;
use codec::Decode;
@@ -59,5 +59,6 @@
fn last_token_id(collection: CollectionId) -> Result<TokenId>;
fn collection_by_id(collection: CollectionId) -> Result<Option<Collection<AccountId>>>;
fn collection_stats() -> Result<CollectionStats>;
+ 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 eth_contract_code(account: H160) -> Option<Vec<u8>> {50 <pallet_unique::UniqueErcSupport<Runtime>>::get_code(&account)51 .or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account))52 .or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))53 }54 fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {55 Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))56 }57 fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {58 Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))59 }60 fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {61 Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))62 }63 fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {64 dispatch_unique_runtime!(collection.last_token_id())65 }66 fn collection_by_id(collection: CollectionId) -> Result<Option<Collection<AccountId>>, DispatchError> {67 Ok(<pallet_common::CollectionById<Runtime>>::get(collection))68 }69 fn collection_stats() -> Result<CollectionStats, DispatchError> {70 Ok(<pallet_common::Pallet<Runtime>>::collection_stats())71 }72 }7374 impl sp_api::Core<Block> for Runtime {75 fn version() -> RuntimeVersion {76 VERSION77 }7879 fn execute_block(block: Block) {80 Executive::execute_block(block)81 }8283 fn initialize_block(header: &<Block as BlockT>::Header) {84 Executive::initialize_block(header)85 }86 }8788 impl sp_api::Metadata<Block> for Runtime {89 fn metadata() -> OpaqueMetadata {90 OpaqueMetadata::new(Runtime::metadata().into())91 }92 }9394 impl sp_block_builder::BlockBuilder<Block> for Runtime {95 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {96 Executive::apply_extrinsic(extrinsic)97 }9899 fn finalize_block() -> <Block as BlockT>::Header {100 Executive::finalize_block()101 }102103 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {104 data.create_extrinsics()105 }106107 fn check_inherents(108 block: Block,109 data: sp_inherents::InherentData,110 ) -> sp_inherents::CheckInherentsResult {111 data.check_extrinsics(&block)112 }113114 // fn random_seed() -> <Block as BlockT>::Hash {115 // RandomnessCollectiveFlip::random_seed().0116 // }117 }118119 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {120 fn validate_transaction(121 source: TransactionSource,122 tx: <Block as BlockT>::Extrinsic,123 hash: <Block as BlockT>::Hash,124 ) -> TransactionValidity {125 Executive::validate_transaction(source, tx, hash)126 }127 }128129 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {130 fn offchain_worker(header: &<Block as BlockT>::Header) {131 Executive::offchain_worker(header)132 }133 }134135 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {136 fn chain_id() -> u64 {137 <Runtime as pallet_evm::Config>::ChainId::get()138 }139140 fn account_basic(address: H160) -> EVMAccount {141 EVM::account_basic(&address)142 }143144 fn gas_price() -> U256 {145 <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()146 }147148 fn account_code_at(address: H160) -> Vec<u8> {149 EVM::account_codes(address)150 }151152 fn author() -> H160 {153 <pallet_evm::Pallet<Runtime>>::find_author()154 }155156 fn storage_at(address: H160, index: U256) -> H256 {157 let mut tmp = [0u8; 32];158 index.to_big_endian(&mut tmp);159 EVM::account_storages(address, H256::from_slice(&tmp[..]))160 }161162 #[allow(clippy::redundant_closure)]163 fn call(164 from: H160,165 to: H160,166 data: Vec<u8>,167 value: U256,168 gas_limit: U256,169 max_fee_per_gas: Option<U256>,170 max_priority_fee_per_gas: Option<U256>,171 nonce: Option<U256>,172 estimate: bool,173 access_list: Option<Vec<(H160, Vec<H256>)>>,174 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {175 let config = if estimate {176 let mut config = <Runtime as pallet_evm::Config>::config().clone();177 config.estimate = true;178 Some(config)179 } else {180 None181 };182183 <Runtime as pallet_evm::Config>::Runner::call(184 from,185 to,186 data,187 value,188 gas_limit.low_u64(),189 max_fee_per_gas,190 max_priority_fee_per_gas,191 nonce,192 access_list.unwrap_or_default(),193 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),194 ).map_err(|err| err.into())195 }196197 #[allow(clippy::redundant_closure)]198 fn create(199 from: H160,200 data: Vec<u8>,201 value: U256,202 gas_limit: U256,203 max_fee_per_gas: Option<U256>,204 max_priority_fee_per_gas: Option<U256>,205 nonce: Option<U256>,206 estimate: bool,207 access_list: Option<Vec<(H160, Vec<H256>)>>,208 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {209 let config = if estimate {210 let mut config = <Runtime as pallet_evm::Config>::config().clone();211 config.estimate = true;212 Some(config)213 } else {214 None215 };216217 <Runtime as pallet_evm::Config>::Runner::create(218 from,219 data,220 value,221 gas_limit.low_u64(),222 max_fee_per_gas,223 max_priority_fee_per_gas,224 nonce,225 access_list.unwrap_or_default(),226 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),227 ).map_err(|err| err.into())228 }229230 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {231 Ethereum::current_transaction_statuses()232 }233234 fn current_block() -> Option<pallet_ethereum::Block> {235 Ethereum::current_block()236 }237238 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {239 Ethereum::current_receipts()240 }241242 fn current_all() -> (243 Option<pallet_ethereum::Block>,244 Option<Vec<pallet_ethereum::Receipt>>,245 Option<Vec<TransactionStatus>>246 ) {247 (248 Ethereum::current_block(),249 Ethereum::current_receipts(),250 Ethereum::current_transaction_statuses()251 )252 }253254 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {255 xts.into_iter().filter_map(|xt| match xt.0.function {256 Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),257 _ => None258 }).collect()259 }260261 fn elasticity() -> Option<Permill> {262 None263 }264 }265266 impl sp_session::SessionKeys<Block> for Runtime {267 fn decode_session_keys(268 encoded: Vec<u8>,269 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {270 SessionKeys::decode_into_raw_public_keys(&encoded)271 }272273 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {274 SessionKeys::generate(seed)275 }276 }277278 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {279 fn slot_duration() -> sp_consensus_aura::SlotDuration {280 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())281 }282283 fn authorities() -> Vec<AuraId> {284 Aura::authorities().to_vec()285 }286 }287288 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {289 fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {290 ParachainSystem::collect_collation_info(header)291 }292 }293294 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {295 fn account_nonce(account: AccountId) -> Index {296 System::account_nonce(account)297 }298 }299300 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {301 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {302 TransactionPayment::query_info(uxt, len)303 }304 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {305 TransactionPayment::query_fee_details(uxt, len)306 }307 }308309 /*310 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>311 for Runtime312 {313 fn call(314 origin: AccountId,315 dest: AccountId,316 value: Balance,317 gas_limit: u64,318 input_data: Vec<u8>,319 ) -> pallet_contracts_primitives::ContractExecResult {320 Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)321 }322323 fn instantiate(324 origin: AccountId,325 endowment: Balance,326 gas_limit: u64,327 code: pallet_contracts_primitives::Code<Hash>,328 data: Vec<u8>,329 salt: Vec<u8>,330 ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>331 {332 Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)333 }334335 fn get_storage(336 address: AccountId,337 key: [u8; 32],338 ) -> pallet_contracts_primitives::GetStorageResult {339 Contracts::get_storage(address, key)340 }341342 fn rent_projection(343 address: AccountId,344 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {345 Contracts::rent_projection(address)346 }347 }348 */349350 #[cfg(feature = "runtime-benchmarks")]351 impl frame_benchmarking::Benchmark<Block> for Runtime {352 fn benchmark_metadata(extra: bool) -> (353 Vec<frame_benchmarking::BenchmarkList>,354 Vec<frame_support::traits::StorageInfo>,355 ) {356 use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};357 use frame_support::traits::StorageInfoTrait;358359 let mut list = Vec::<BenchmarkList>::new();360361 list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);362 list_benchmark!(list, extra, pallet_unique, Unique);363 list_benchmark!(list, extra, pallet_inflation, Inflation);364 list_benchmark!(list, extra, pallet_fungible, Fungible);365 list_benchmark!(list, extra, pallet_refungible, Refungible);366 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);367 // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);368369 let storage_info = AllPalletsReversedWithSystemFirst::storage_info();370371 return (list, storage_info)372 }373374 fn dispatch_benchmark(375 config: frame_benchmarking::BenchmarkConfig376 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {377 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};378379 let allowlist: Vec<TrackedStorageKey> = vec![380 // Block Number381 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),382 // Total Issuance383 hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),384 // Execution Phase385 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),386 // Event Count387 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),388 // System Events389 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),390 ];391392 let mut batches = Vec::<BenchmarkBatch>::new();393 let params = (&config, &allowlist);394395 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);396 add_benchmark!(params, batches, pallet_unique, Unique);397 add_benchmark!(params, batches, pallet_inflation, Inflation);398 add_benchmark!(params, batches, pallet_fungible, Fungible);399 add_benchmark!(params, batches, pallet_refungible, Refungible);400 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);401 // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);402403 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }404 Ok(batches)405 }406 }407 }408 }409}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 eth_contract_code(account: H160) -> Option<Vec<u8>> {50 <pallet_unique::UniqueErcSupport<Runtime>>::get_code(&account)51 .or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account))52 .or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))53 }54 fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {55 Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))56 }57 fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {58 Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))59 }60 fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {61 Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))62 }63 fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {64 dispatch_unique_runtime!(collection.last_token_id())65 }66 fn collection_by_id(collection: CollectionId) -> Result<Option<Collection<AccountId>>, DispatchError> {67 Ok(<pallet_common::CollectionById<Runtime>>::get(collection))68 }69 fn collection_stats() -> Result<CollectionStats, DispatchError> {70 Ok(<pallet_common::Pallet<Runtime>>::collection_stats())71 }7273 fn effective_collection_limits(collection: CollectionId) -> Result<Option<CollectionLimits>, DispatchError> {74 Ok(<pallet_common::Pallet<Runtime>>::effective_collection_limits(collection))75 }76 }7778 impl sp_api::Core<Block> for Runtime {79 fn version() -> RuntimeVersion {80 VERSION81 }8283 fn execute_block(block: Block) {84 Executive::execute_block(block)85 }8687 fn initialize_block(header: &<Block as BlockT>::Header) {88 Executive::initialize_block(header)89 }90 }9192 impl sp_api::Metadata<Block> for Runtime {93 fn metadata() -> OpaqueMetadata {94 OpaqueMetadata::new(Runtime::metadata().into())95 }96 }9798 impl sp_block_builder::BlockBuilder<Block> for Runtime {99 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {100 Executive::apply_extrinsic(extrinsic)101 }102103 fn finalize_block() -> <Block as BlockT>::Header {104 Executive::finalize_block()105 }106107 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {108 data.create_extrinsics()109 }110111 fn check_inherents(112 block: Block,113 data: sp_inherents::InherentData,114 ) -> sp_inherents::CheckInherentsResult {115 data.check_extrinsics(&block)116 }117118 // fn random_seed() -> <Block as BlockT>::Hash {119 // RandomnessCollectiveFlip::random_seed().0120 // }121 }122123 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {124 fn validate_transaction(125 source: TransactionSource,126 tx: <Block as BlockT>::Extrinsic,127 hash: <Block as BlockT>::Hash,128 ) -> TransactionValidity {129 Executive::validate_transaction(source, tx, hash)130 }131 }132133 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {134 fn offchain_worker(header: &<Block as BlockT>::Header) {135 Executive::offchain_worker(header)136 }137 }138139 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {140 fn chain_id() -> u64 {141 <Runtime as pallet_evm::Config>::ChainId::get()142 }143144 fn account_basic(address: H160) -> EVMAccount {145 EVM::account_basic(&address)146 }147148 fn gas_price() -> U256 {149 <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()150 }151152 fn account_code_at(address: H160) -> Vec<u8> {153 EVM::account_codes(address)154 }155156 fn author() -> H160 {157 <pallet_evm::Pallet<Runtime>>::find_author()158 }159160 fn storage_at(address: H160, index: U256) -> H256 {161 let mut tmp = [0u8; 32];162 index.to_big_endian(&mut tmp);163 EVM::account_storages(address, H256::from_slice(&tmp[..]))164 }165166 #[allow(clippy::redundant_closure)]167 fn call(168 from: H160,169 to: H160,170 data: Vec<u8>,171 value: U256,172 gas_limit: U256,173 max_fee_per_gas: Option<U256>,174 max_priority_fee_per_gas: Option<U256>,175 nonce: Option<U256>,176 estimate: bool,177 access_list: Option<Vec<(H160, Vec<H256>)>>,178 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {179 let config = if estimate {180 let mut config = <Runtime as pallet_evm::Config>::config().clone();181 config.estimate = true;182 Some(config)183 } else {184 None185 };186187 <Runtime as pallet_evm::Config>::Runner::call(188 from,189 to,190 data,191 value,192 gas_limit.low_u64(),193 max_fee_per_gas,194 max_priority_fee_per_gas,195 nonce,196 access_list.unwrap_or_default(),197 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),198 ).map_err(|err| err.into())199 }200201 #[allow(clippy::redundant_closure)]202 fn create(203 from: H160,204 data: Vec<u8>,205 value: U256,206 gas_limit: U256,207 max_fee_per_gas: Option<U256>,208 max_priority_fee_per_gas: Option<U256>,209 nonce: Option<U256>,210 estimate: bool,211 access_list: Option<Vec<(H160, Vec<H256>)>>,212 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {213 let config = if estimate {214 let mut config = <Runtime as pallet_evm::Config>::config().clone();215 config.estimate = true;216 Some(config)217 } else {218 None219 };220221 <Runtime as pallet_evm::Config>::Runner::create(222 from,223 data,224 value,225 gas_limit.low_u64(),226 max_fee_per_gas,227 max_priority_fee_per_gas,228 nonce,229 access_list.unwrap_or_default(),230 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),231 ).map_err(|err| err.into())232 }233234 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {235 Ethereum::current_transaction_statuses()236 }237238 fn current_block() -> Option<pallet_ethereum::Block> {239 Ethereum::current_block()240 }241242 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {243 Ethereum::current_receipts()244 }245246 fn current_all() -> (247 Option<pallet_ethereum::Block>,248 Option<Vec<pallet_ethereum::Receipt>>,249 Option<Vec<TransactionStatus>>250 ) {251 (252 Ethereum::current_block(),253 Ethereum::current_receipts(),254 Ethereum::current_transaction_statuses()255 )256 }257258 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {259 xts.into_iter().filter_map(|xt| match xt.0.function {260 Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),261 _ => None262 }).collect()263 }264265 fn elasticity() -> Option<Permill> {266 None267 }268 }269270 impl sp_session::SessionKeys<Block> for Runtime {271 fn decode_session_keys(272 encoded: Vec<u8>,273 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {274 SessionKeys::decode_into_raw_public_keys(&encoded)275 }276277 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {278 SessionKeys::generate(seed)279 }280 }281282 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {283 fn slot_duration() -> sp_consensus_aura::SlotDuration {284 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())285 }286287 fn authorities() -> Vec<AuraId> {288 Aura::authorities().to_vec()289 }290 }291292 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {293 fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {294 ParachainSystem::collect_collation_info(header)295 }296 }297298 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {299 fn account_nonce(account: AccountId) -> Index {300 System::account_nonce(account)301 }302 }303304 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {305 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {306 TransactionPayment::query_info(uxt, len)307 }308 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {309 TransactionPayment::query_fee_details(uxt, len)310 }311 }312313 /*314 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>315 for Runtime316 {317 fn call(318 origin: AccountId,319 dest: AccountId,320 value: Balance,321 gas_limit: u64,322 input_data: Vec<u8>,323 ) -> pallet_contracts_primitives::ContractExecResult {324 Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)325 }326327 fn instantiate(328 origin: AccountId,329 endowment: Balance,330 gas_limit: u64,331 code: pallet_contracts_primitives::Code<Hash>,332 data: Vec<u8>,333 salt: Vec<u8>,334 ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>335 {336 Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)337 }338339 fn get_storage(340 address: AccountId,341 key: [u8; 32],342 ) -> pallet_contracts_primitives::GetStorageResult {343 Contracts::get_storage(address, key)344 }345346 fn rent_projection(347 address: AccountId,348 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {349 Contracts::rent_projection(address)350 }351 }352 */353354 #[cfg(feature = "runtime-benchmarks")]355 impl frame_benchmarking::Benchmark<Block> for Runtime {356 fn benchmark_metadata(extra: bool) -> (357 Vec<frame_benchmarking::BenchmarkList>,358 Vec<frame_support::traits::StorageInfo>,359 ) {360 use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};361 use frame_support::traits::StorageInfoTrait;362363 let mut list = Vec::<BenchmarkList>::new();364365 list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);366 list_benchmark!(list, extra, pallet_unique, Unique);367 list_benchmark!(list, extra, pallet_inflation, Inflation);368 list_benchmark!(list, extra, pallet_fungible, Fungible);369 list_benchmark!(list, extra, pallet_refungible, Refungible);370 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);371 // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);372373 let storage_info = AllPalletsReversedWithSystemFirst::storage_info();374375 return (list, storage_info)376 }377378 fn dispatch_benchmark(379 config: frame_benchmarking::BenchmarkConfig380 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {381 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};382383 let allowlist: Vec<TrackedStorageKey> = vec![384 // Block Number385 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),386 // Total Issuance387 hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),388 // Execution Phase389 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),390 // Event Count391 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),392 // System Events393 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),394 ];395396 let mut batches = Vec::<BenchmarkBatch>::new();397 let params = (&config, &allowlist);398399 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);400 add_benchmark!(params, batches, pallet_unique, Unique);401 add_benchmark!(params, batches, pallet_inflation, Inflation);402 add_benchmark!(params, batches, pallet_fungible, Fungible);403 add_benchmark!(params, batches, pallet_refungible, Refungible);404 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);405 // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);406407 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }408 Ok(batches)409 }410 }411 }412 }413}tests/src/interfaces/augment-api-errors.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-errors.ts
+++ b/tests/src/interfaces/augment-api-errors.ts
@@ -105,6 +105,10 @@
**/
NoPermission: AugmentedError<ApiType>;
/**
+ * Not sufficient founds to perform action
+ **/
+ NotSufficientFounds: AugmentedError<ApiType>;
+ /**
* Tried to enable permissions which are only permitted to be disabled
**/
OwnerPermissionsCantBeReverted: AugmentedError<ApiType>;
tests/src/interfaces/augment-api-rpc.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-rpc.ts
+++ b/tests/src/interfaces/augment-api-rpc.ts
@@ -1,7 +1,7 @@
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
/* eslint-disable */
-import type { PalletCommonAccountBasicCrossAccountIdRepr, UpDataStructsCollection, UpDataStructsCollectionStats } from './unique';
+import type { PalletCommonAccountBasicCrossAccountIdRepr, UpDataStructsCollection, UpDataStructsCollectionLimits, UpDataStructsCollectionStats } from './unique';
import type { AugmentedRpc } from '@polkadot/rpc-core/types';
import type { Metadata, StorageKey } from '@polkadot/types';
import type { Bytes, HashMap, Json, Null, Option, Text, U256, U64, Vec, bool, u128, u32, u64 } from '@polkadot/types-codec';
@@ -604,6 +604,10 @@
**/
constMetadata: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Bytes>>;
/**
+ * Get effective collection limits
+ **/
+ effectiveCollectionLimits: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<UpDataStructsCollectionLimits>>>;
+ /**
* Get last token id
**/
lastTokenId: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u32>>;
tests/src/interfaces/augment-types.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-types.ts
+++ b/tests/src/interfaces/augment-types.ts
@@ -1,7 +1,7 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
-import type { CumulusPalletDmpQueueCall, CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueueError, CumulusPalletDmpQueueEvent, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemCall, CumulusPalletParachainSystemError, CumulusPalletParachainSystemEvent, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmCall, CumulusPalletXcmError, CumulusPalletXcmEvent, CumulusPalletXcmpQueueCall, CumulusPalletXcmpQueueError, CumulusPalletXcmpQueueEvent, CumulusPalletXcmpQueueInboundChannelDetails, CumulusPalletXcmpQueueInboundState, CumulusPalletXcmpQueueOutboundChannelDetails, CumulusPalletXcmpQueueOutboundState, CumulusPalletXcmpQueueQueueConfigData, CumulusPrimitivesParachainInherentParachainInherentData, EthbloomBloom, EthereumBlock, EthereumHeader, EthereumLog, EthereumReceiptEip658ReceiptData, EthereumReceiptReceiptV3, EthereumTransactionAccessListItem, EthereumTransactionEip1559Transaction, EthereumTransactionEip2930Transaction, EthereumTransactionLegacyTransaction, EthereumTransactionTransactionAction, EthereumTransactionTransactionSignature, EthereumTransactionTransactionV2, EthereumTypesHashH64, EvmCoreErrorExitError, EvmCoreErrorExitFatal, EvmCoreErrorExitReason, EvmCoreErrorExitRevert, EvmCoreErrorExitSucceed, FpRpcTransactionStatus, FrameSupportPalletId, FrameSupportTokensMiscBalanceStatus, FrameSupportWeightsDispatchClass, FrameSupportWeightsDispatchInfo, FrameSupportWeightsPays, FrameSupportWeightsPerDispatchClassU32, FrameSupportWeightsPerDispatchClassU64, FrameSupportWeightsPerDispatchClassWeightsPerClass, FrameSupportWeightsRuntimeDbWeight, FrameSupportWeightsWeightToFeeCoefficient, FrameSystemAccountInfo, FrameSystemCall, FrameSystemError, FrameSystemEvent, FrameSystemEventRecord, FrameSystemExtensionsCheckGenesis, FrameSystemExtensionsCheckNonce, FrameSystemExtensionsCheckSpecVersion, FrameSystemExtensionsCheckWeight, FrameSystemLastRuntimeUpgradeInfo, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, FrameSystemLimitsWeightsPerClass, FrameSystemPhase, OrmlVestingModuleCall, OrmlVestingModuleError, OrmlVestingModuleEvent, OrmlVestingVestingSchedule, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesCall, PalletBalancesError, PalletBalancesEvent, PalletBalancesReasons, PalletBalancesReleases, PalletBalancesReserveData, PalletCommonAccountBasicCrossAccountIdRepr, PalletCommonError, PalletCommonEvent, PalletEthereumCall, PalletEthereumError, PalletEthereumEvent, PalletEvmCall, PalletEvmCoderSubstrateError, PalletEvmContractHelpersError, PalletEvmContractHelpersSponsoringModeT, PalletEvmError, PalletEvmEvent, PalletEvmMigrationCall, PalletEvmMigrationError, PalletFungibleError, PalletInflationCall, PalletNonfungibleError, PalletNonfungibleItemData, PalletRefungibleError, PalletRefungibleItemData, PalletSudoCall, PalletSudoError, PalletSudoEvent, PalletTemplateTransactionPaymentCall, PalletTemplateTransactionPaymentChargeTransactionPayment, PalletTimestampCall, PalletTransactionPaymentReleases, PalletTreasuryCall, PalletTreasuryError, PalletTreasuryEvent, PalletTreasuryProposal, PalletUniqueCall, PalletUniqueError, PalletUniqueRawEvent, PalletXcmCall, PalletXcmError, PalletXcmEvent, PolkadotCorePrimitivesInboundDownwardMessage, PolkadotCorePrimitivesInboundHrmpMessage, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotParachainPrimitivesXcmpMessageFormat, PolkadotPrimitivesV1AbridgedHostConfiguration, PolkadotPrimitivesV1AbridgedHrmpChannel, PolkadotPrimitivesV1PersistedValidationData, PolkadotPrimitivesV1UpgradeRestriction, SpCoreEcdsaSignature, SpCoreEd25519Signature, SpCoreSr25519Signature, SpRuntimeArithmeticError, SpRuntimeDigest, SpRuntimeDigestDigestItem, SpRuntimeDispatchError, SpRuntimeModuleError, SpRuntimeMultiSignature, SpRuntimeTokenError, SpTrieStorageProof, SpVersionRuntimeVersion, UniqueRuntimeRuntime, UpDataStructsAccessMode, UpDataStructsCollection, UpDataStructsCollectionLimits, UpDataStructsCollectionMode, UpDataStructsCollectionStats, UpDataStructsCreateCollectionData, UpDataStructsCreateFungibleData, UpDataStructsCreateItemData, UpDataStructsCreateItemExData, UpDataStructsCreateNftData, UpDataStructsCreateNftExData, UpDataStructsCreateReFungibleData, UpDataStructsCreateRefungibleExData, UpDataStructsMetaUpdatePermission, UpDataStructsSchemaVersion, UpDataStructsSponsoringRateLimit, UpDataStructsSponsorshipState, XcmDoubleEncoded, XcmV0Junction, XcmV0JunctionBodyId, XcmV0JunctionBodyPart, XcmV0JunctionNetworkId, XcmV0MultiAsset, XcmV0MultiLocation, XcmV0Order, XcmV0OriginKind, XcmV0Response, XcmV0Xcm, XcmV1Junction, XcmV1MultiAsset, XcmV1MultiLocation, XcmV1MultiassetAssetId, XcmV1MultiassetAssetInstance, XcmV1MultiassetFungibility, XcmV1MultiassetMultiAssetFilter, XcmV1MultiassetMultiAssets, XcmV1MultiassetWildFungibility, XcmV1MultiassetWildMultiAsset, XcmV1MultilocationJunctions, XcmV1Order, XcmV1Response, XcmV1Xcm, XcmV2Instruction, XcmV2Response, XcmV2TraitsError, XcmV2TraitsOutcome, XcmV2WeightLimit, XcmV2Xcm, XcmVersionedMultiAssets, XcmVersionedMultiLocation, XcmVersionedXcm } from './unique';
+import type { CumulusPalletDmpQueueCall, CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueueError, CumulusPalletDmpQueueEvent, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemCall, CumulusPalletParachainSystemError, CumulusPalletParachainSystemEvent, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmCall, CumulusPalletXcmError, CumulusPalletXcmEvent, CumulusPalletXcmpQueueCall, CumulusPalletXcmpQueueError, CumulusPalletXcmpQueueEvent, CumulusPalletXcmpQueueInboundChannelDetails, CumulusPalletXcmpQueueInboundState, CumulusPalletXcmpQueueOutboundChannelDetails, CumulusPalletXcmpQueueOutboundState, CumulusPalletXcmpQueueQueueConfigData, CumulusPrimitivesParachainInherentParachainInherentData, EthbloomBloom, EthereumBlock, EthereumHeader, EthereumLog, EthereumReceiptEip658ReceiptData, EthereumReceiptReceiptV3, EthereumTransactionAccessListItem, EthereumTransactionEip1559Transaction, EthereumTransactionEip2930Transaction, EthereumTransactionLegacyTransaction, EthereumTransactionTransactionAction, EthereumTransactionTransactionSignature, EthereumTransactionTransactionV2, EthereumTypesHashH64, EvmCoreErrorExitError, EvmCoreErrorExitFatal, EvmCoreErrorExitReason, EvmCoreErrorExitRevert, EvmCoreErrorExitSucceed, FpRpcTransactionStatus, FrameSupportPalletId, FrameSupportTokensMiscBalanceStatus, FrameSupportWeightsDispatchClass, FrameSupportWeightsDispatchInfo, FrameSupportWeightsPays, FrameSupportWeightsPerDispatchClassU32, FrameSupportWeightsPerDispatchClassU64, FrameSupportWeightsPerDispatchClassWeightsPerClass, FrameSupportWeightsRuntimeDbWeight, FrameSupportWeightsWeightToFeeCoefficient, FrameSystemAccountInfo, FrameSystemCall, FrameSystemError, FrameSystemEvent, FrameSystemEventRecord, FrameSystemExtensionsCheckGenesis, FrameSystemExtensionsCheckNonce, FrameSystemExtensionsCheckSpecVersion, FrameSystemExtensionsCheckWeight, FrameSystemLastRuntimeUpgradeInfo, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, FrameSystemLimitsWeightsPerClass, FrameSystemPhase, OpalRuntimeRuntime, OrmlVestingModuleCall, OrmlVestingModuleError, OrmlVestingModuleEvent, OrmlVestingVestingSchedule, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesCall, PalletBalancesError, PalletBalancesEvent, PalletBalancesReasons, PalletBalancesReleases, PalletBalancesReserveData, PalletCommonAccountBasicCrossAccountIdRepr, PalletCommonError, PalletCommonEvent, PalletEthereumCall, PalletEthereumError, PalletEthereumEvent, PalletEvmCall, PalletEvmCoderSubstrateError, PalletEvmContractHelpersError, PalletEvmContractHelpersSponsoringModeT, PalletEvmError, PalletEvmEvent, PalletEvmMigrationCall, PalletEvmMigrationError, PalletFungibleError, PalletInflationCall, PalletNonfungibleError, PalletNonfungibleItemData, PalletRefungibleError, PalletRefungibleItemData, PalletSudoCall, PalletSudoError, PalletSudoEvent, PalletTemplateTransactionPaymentCall, PalletTemplateTransactionPaymentChargeTransactionPayment, PalletTimestampCall, PalletTransactionPaymentReleases, PalletTreasuryCall, PalletTreasuryError, PalletTreasuryEvent, PalletTreasuryProposal, PalletUniqueCall, PalletUniqueError, PalletUniqueRawEvent, PalletXcmCall, PalletXcmError, PalletXcmEvent, PolkadotCorePrimitivesInboundDownwardMessage, PolkadotCorePrimitivesInboundHrmpMessage, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotParachainPrimitivesXcmpMessageFormat, PolkadotPrimitivesV1AbridgedHostConfiguration, PolkadotPrimitivesV1AbridgedHrmpChannel, PolkadotPrimitivesV1PersistedValidationData, PolkadotPrimitivesV1UpgradeRestriction, SpCoreEcdsaSignature, SpCoreEd25519Signature, SpCoreSr25519Signature, SpRuntimeArithmeticError, SpRuntimeDigest, SpRuntimeDigestDigestItem, SpRuntimeDispatchError, SpRuntimeModuleError, SpRuntimeMultiSignature, SpRuntimeTokenError, SpTrieStorageProof, SpVersionRuntimeVersion, UpDataStructsAccessMode, UpDataStructsCollection, UpDataStructsCollectionLimits, UpDataStructsCollectionMode, UpDataStructsCollectionStats, UpDataStructsCreateCollectionData, UpDataStructsCreateFungibleData, UpDataStructsCreateItemData, UpDataStructsCreateItemExData, UpDataStructsCreateNftData, UpDataStructsCreateNftExData, UpDataStructsCreateReFungibleData, UpDataStructsCreateRefungibleExData, UpDataStructsMetaUpdatePermission, UpDataStructsSchemaVersion, UpDataStructsSponsoringRateLimit, UpDataStructsSponsorshipState, XcmDoubleEncoded, XcmV0Junction, XcmV0JunctionBodyId, XcmV0JunctionBodyPart, XcmV0JunctionNetworkId, XcmV0MultiAsset, XcmV0MultiLocation, XcmV0Order, XcmV0OriginKind, XcmV0Response, XcmV0Xcm, XcmV1Junction, XcmV1MultiAsset, XcmV1MultiLocation, XcmV1MultiassetAssetId, XcmV1MultiassetAssetInstance, XcmV1MultiassetFungibility, XcmV1MultiassetMultiAssetFilter, XcmV1MultiassetMultiAssets, XcmV1MultiassetWildFungibility, XcmV1MultiassetWildMultiAsset, XcmV1MultilocationJunctions, XcmV1Order, XcmV1Response, XcmV1Xcm, XcmV2Instruction, XcmV2Response, XcmV2TraitsError, XcmV2TraitsOutcome, XcmV2WeightLimit, XcmV2Xcm, XcmVersionedMultiAssets, XcmVersionedMultiLocation, XcmVersionedXcm } from './unique';
import type { Data, StorageKey } from '@polkadot/types';
import type { BitVec, Bool, Bytes, I128, I16, I256, I32, I64, I8, Json, Null, Raw, Text, Type, U128, U16, U256, U32, U64, U8, USize, bool, i128, i16, i256, i32, i64, i8, u128, u16, u256, u32, u64, u8, usize } from '@polkadot/types-codec';
import type { AssetApproval, AssetApprovalKey, AssetBalance, AssetDestroyWitness, AssetDetails, AssetMetadata, TAssetBalance, TAssetDepositBalance } from '@polkadot/types/interfaces/assets';
@@ -18,7 +18,7 @@
import type { StatementKind } from '@polkadot/types/interfaces/claims';
import type { CollectiveOrigin, MemberCount, ProposalIndex, Votes, VotesTo230 } from '@polkadot/types/interfaces/collective';
import type { AuthorityId, RawVRFOutput } from '@polkadot/types/interfaces/consensus';
-import type { AliveContractInfo, CodeHash, CodeUploadRequest, CodeUploadResult, CodeUploadResultValue, ContractCallFlags, ContractCallRequest, ContractExecResult, ContractExecResultErr, ContractExecResultErrModule, ContractExecResultOk, ContractExecResultResult, ContractExecResultSuccessTo255, ContractExecResultSuccessTo260, ContractExecResultTo255, ContractExecResultTo260, ContractExecResultTo267, ContractInfo, ContractInstantiateResult, ContractInstantiateResultTo267, ContractReturnFlags, ContractStorageKey, DeletedContract, ExecReturnValue, Gas, HostFnWeights, HostFnWeightsTo264, InstantiateRequest, InstantiateReturnValue, InstantiateReturnValueTo267, InstructionWeights, Limits, LimitsTo264, PrefabWasmModule, RentProjection, Schedule, ScheduleTo212, ScheduleTo258, ScheduleTo264, SeedOf, StorageDeposit, TombstoneContractInfo, TrieId } from '@polkadot/types/interfaces/contracts';
+import type { AliveContractInfo, CodeHash, CodeSource, CodeUploadRequest, CodeUploadResult, CodeUploadResultValue, ContractCallFlags, ContractCallRequest, ContractExecResult, ContractExecResultErr, ContractExecResultErrModule, ContractExecResultOk, ContractExecResultResult, ContractExecResultSuccessTo255, ContractExecResultSuccessTo260, ContractExecResultTo255, ContractExecResultTo260, ContractExecResultTo267, ContractInfo, ContractInstantiateResult, ContractInstantiateResultTo267, ContractInstantiateResultTo299, ContractReturnFlags, ContractStorageKey, DeletedContract, ExecReturnValue, Gas, HostFnWeights, HostFnWeightsTo264, InstantiateRequest, InstantiateRequestV1, InstantiateRequestV2, InstantiateReturnValue, InstantiateReturnValueOk, InstantiateReturnValueTo267, InstructionWeights, Limits, LimitsTo264, PrefabWasmModule, RentProjection, Schedule, ScheduleTo212, ScheduleTo258, ScheduleTo264, SeedOf, StorageDeposit, TombstoneContractInfo, TrieId } from '@polkadot/types/interfaces/contracts';
import type { ContractConstructorSpecLatest, ContractConstructorSpecV0, ContractConstructorSpecV1, ContractConstructorSpecV2, ContractConstructorSpecV3, ContractContractSpecV0, ContractContractSpecV1, ContractContractSpecV2, ContractContractSpecV3, ContractCryptoHasher, ContractDiscriminant, ContractDisplayName, ContractEventParamSpecLatest, ContractEventParamSpecV0, ContractEventParamSpecV2, ContractEventSpecLatest, ContractEventSpecV0, ContractEventSpecV1, ContractEventSpecV2, ContractLayoutArray, ContractLayoutCell, ContractLayoutEnum, ContractLayoutHash, ContractLayoutHashingStrategy, ContractLayoutKey, ContractLayoutStruct, ContractLayoutStructField, ContractMessageParamSpecLatest, ContractMessageParamSpecV0, ContractMessageParamSpecV2, ContractMessageSpecLatest, ContractMessageSpecV0, ContractMessageSpecV1, ContractMessageSpecV2, ContractMetadata, ContractMetadataLatest, ContractMetadataV0, ContractMetadataV1, ContractMetadataV2, ContractMetadataV3, ContractProject, ContractProjectContract, ContractProjectInfo, ContractProjectSource, ContractProjectV0, ContractSelector, ContractStorageLayout, ContractTypeSpec } from '@polkadot/types/interfaces/contractsAbi';
import type { FundIndex, FundInfo, LastContribution, TrieIndex } from '@polkadot/types/interfaces/crowdloan';
import type { ConfigData, MessageId, OverweightIndex, PageCounter, PageIndexData } from '@polkadot/types/interfaces/cumulus';
@@ -198,6 +198,7 @@
ClassMetadata: ClassMetadata;
CodecHash: CodecHash;
CodeHash: CodeHash;
+ CodeSource: CodeSource;
CodeUploadRequest: CodeUploadRequest;
CodeUploadResult: CodeUploadResult;
CodeUploadResultValue: CodeUploadResultValue;
@@ -250,6 +251,7 @@
ContractInfo: ContractInfo;
ContractInstantiateResult: ContractInstantiateResult;
ContractInstantiateResultTo267: ContractInstantiateResultTo267;
+ ContractInstantiateResultTo299: ContractInstantiateResultTo299;
ContractLayoutArray: ContractLayoutArray;
ContractLayoutCell: ContractLayoutCell;
ContractLayoutEnum: ContractLayoutEnum;
@@ -591,7 +593,10 @@
InstanceId: InstanceId;
InstanceMetadata: InstanceMetadata;
InstantiateRequest: InstantiateRequest;
+ InstantiateRequestV1: InstantiateRequestV1;
+ InstantiateRequestV2: InstantiateRequestV2;
InstantiateReturnValue: InstantiateReturnValue;
+ InstantiateReturnValueOk: InstantiateReturnValueOk;
InstantiateReturnValueTo267: InstantiateReturnValueTo267;
InstructionV2: InstructionV2;
InstructionWeights: InstructionWeights;
@@ -707,6 +712,7 @@
OffchainAccuracyCompact: OffchainAccuracyCompact;
OffenceDetails: OffenceDetails;
Offender: Offender;
+ OpalRuntimeRuntime: OpalRuntimeRuntime;
OpaqueCall: OpaqueCall;
OpaqueMultiaddr: OpaqueMultiaddr;
OpaqueNetworkState: OpaqueNetworkState;
@@ -1146,7 +1152,6 @@
UnappliedSlash: UnappliedSlash;
UnappliedSlashOther: UnappliedSlashOther;
UncleEntryItem: UncleEntryItem;
- UniqueRuntimeRuntime: UniqueRuntimeRuntime;
UnknownTransaction: UnknownTransaction;
UnlockChunk: UnlockChunk;
UnrewardedRelayer: UnrewardedRelayer;
tests/src/interfaces/lookup.tsdiffbeforeafterboth--- a/tests/src/interfaces/lookup.ts
+++ b/tests/src/interfaces/lookup.ts
@@ -1756,7 +1756,7 @@
}
},
/**
- * Lookup225: frame_system::EventRecord<unique_runtime::Event, primitive_types::H256>
+ * Lookup225: frame_system::EventRecord<opal_runtime::Event, primitive_types::H256>
**/
FrameSystemEventRecord: {
phase: 'FrameSystemPhase',
@@ -2240,7 +2240,7 @@
* Lookup297: pallet_common::pallet::Error<T>
**/
PalletCommonError: {
- _enum: ['CollectionNotFound', 'MustBeTokenOwner', 'NoPermission', 'PublicMintingNotAllowed', 'AddressNotInAllowlist', 'CollectionNameLimitExceeded', 'CollectionDescriptionLimitExceeded', 'CollectionTokenPrefixLimitExceeded', 'TotalCollectionsLimitExceeded', 'TokenVariableDataLimitExceeded', 'CollectionAdminCountExceeded', 'CollectionLimitBoundsExceeded', 'OwnerPermissionsCantBeReverted', 'TransferNotAllowed', 'AccountTokenLimitExceeded', 'CollectionTokenLimitExceeded', 'MetadataFlagFrozen', 'TokenNotFound', 'TokenValueTooLow', 'ApprovedValueTooLow', 'CantApproveMoreThanOwned', 'AddressIsZero', 'UnsupportedOperation']
+ _enum: ['CollectionNotFound', 'MustBeTokenOwner', 'NoPermission', 'PublicMintingNotAllowed', 'AddressNotInAllowlist', 'CollectionNameLimitExceeded', 'CollectionDescriptionLimitExceeded', 'CollectionTokenPrefixLimitExceeded', 'TotalCollectionsLimitExceeded', 'TokenVariableDataLimitExceeded', 'CollectionAdminCountExceeded', 'CollectionLimitBoundsExceeded', 'OwnerPermissionsCantBeReverted', 'TransferNotAllowed', 'AccountTokenLimitExceeded', 'CollectionTokenLimitExceeded', 'MetadataFlagFrozen', 'TokenNotFound', 'TokenValueTooLow', 'ApprovedValueTooLow', 'CantApproveMoreThanOwned', 'AddressIsZero', 'UnsupportedOperation', 'NotSufficientFounds']
},
/**
* Lookup299: pallet_fungible::pallet::Error<T>
@@ -2417,11 +2417,11 @@
**/
FrameSystemExtensionsCheckWeight: 'Null',
/**
- * Lookup345: pallet_template_transaction_payment::ChargeTransactionPayment<unique_runtime::Runtime>
+ * Lookup345: pallet_template_transaction_payment::ChargeTransactionPayment<opal_runtime::Runtime>
**/
PalletTemplateTransactionPaymentChargeTransactionPayment: 'Compact<u128>',
/**
- * Lookup346: unique_runtime::Runtime
+ * Lookup346: opal_runtime::Runtime
**/
- UniqueRuntimeRuntime: 'Null'
+ OpalRuntimeRuntime: 'Null'
};
tests/src/interfaces/types-lookup.tsdiffbeforeafterboth--- a/tests/src/interfaces/types-lookup.ts
+++ b/tests/src/interfaces/types-lookup.ts
@@ -2462,7 +2462,8 @@
readonly isCantApproveMoreThanOwned: boolean;
readonly isAddressIsZero: boolean;
readonly isUnsupportedOperation: boolean;
- readonly type: 'CollectionNotFound' | 'MustBeTokenOwner' | 'NoPermission' | 'PublicMintingNotAllowed' | 'AddressNotInAllowlist' | 'CollectionNameLimitExceeded' | 'CollectionDescriptionLimitExceeded' | 'CollectionTokenPrefixLimitExceeded' | 'TotalCollectionsLimitExceeded' | 'TokenVariableDataLimitExceeded' | 'CollectionAdminCountExceeded' | 'CollectionLimitBoundsExceeded' | 'OwnerPermissionsCantBeReverted' | 'TransferNotAllowed' | 'AccountTokenLimitExceeded' | 'CollectionTokenLimitExceeded' | 'MetadataFlagFrozen' | 'TokenNotFound' | 'TokenValueTooLow' | 'ApprovedValueTooLow' | 'CantApproveMoreThanOwned' | 'AddressIsZero' | 'UnsupportedOperation';
+ readonly isNotSufficientFounds: boolean;
+ readonly type: 'CollectionNotFound' | 'MustBeTokenOwner' | 'NoPermission' | 'PublicMintingNotAllowed' | 'AddressNotInAllowlist' | 'CollectionNameLimitExceeded' | 'CollectionDescriptionLimitExceeded' | 'CollectionTokenPrefixLimitExceeded' | 'TotalCollectionsLimitExceeded' | 'TokenVariableDataLimitExceeded' | 'CollectionAdminCountExceeded' | 'CollectionLimitBoundsExceeded' | 'OwnerPermissionsCantBeReverted' | 'TransferNotAllowed' | 'AccountTokenLimitExceeded' | 'CollectionTokenLimitExceeded' | 'MetadataFlagFrozen' | 'TokenNotFound' | 'TokenValueTooLow' | 'ApprovedValueTooLow' | 'CantApproveMoreThanOwned' | 'AddressIsZero' | 'UnsupportedOperation' | 'NotSufficientFounds';
}
/** @name PalletFungibleError (299) */
@@ -2643,7 +2644,7 @@
/** @name PalletTemplateTransactionPaymentChargeTransactionPayment (345) */
export interface PalletTemplateTransactionPaymentChargeTransactionPayment extends Compact<u128> {}
- /** @name UniqueRuntimeRuntime (346) */
- export type UniqueRuntimeRuntime = Null;
+ /** @name OpalRuntimeRuntime (346) */
+ export type OpalRuntimeRuntime = Null;
} // declare module
tests/src/interfaces/unique/definitions.tsdiffbeforeafterboth--- a/tests/src/interfaces/unique/definitions.ts
+++ b/tests/src/interfaces/unique/definitions.ts
@@ -55,5 +55,6 @@
collectionById: fun('Get collection by specified id', [collectionParam], 'Option<UpDataStructsCollection>'),
collectionStats: fun('Get collection stats', [], 'UpDataStructsCollectionStats'),
allowed: fun('Check if user is allowed to use collection', [collectionParam, crossAccountParam()], 'bool'),
+ effectiveCollectionLimits: fun('Get effective collection limits', [collectionParam], 'Option<UpDataStructsCollectionLimits>'),
},
};
tests/src/interfaces/unique/types.tsdiffbeforeafterboth--- a/tests/src/interfaces/unique/types.ts
+++ b/tests/src/interfaces/unique/types.ts
@@ -654,6 +654,9 @@
readonly type: 'ApplyExtrinsic' | 'Finalization' | 'Initialization';
}
+/** @name OpalRuntimeRuntime */
+export interface OpalRuntimeRuntime extends Null {}
+
/** @name OrmlVestingModuleCall */
export interface OrmlVestingModuleCall extends Enum {
readonly isClaim: boolean;
@@ -892,7 +895,8 @@
readonly isCantApproveMoreThanOwned: boolean;
readonly isAddressIsZero: boolean;
readonly isUnsupportedOperation: boolean;
- readonly type: 'CollectionNotFound' | 'MustBeTokenOwner' | 'NoPermission' | 'PublicMintingNotAllowed' | 'AddressNotInAllowlist' | 'CollectionNameLimitExceeded' | 'CollectionDescriptionLimitExceeded' | 'CollectionTokenPrefixLimitExceeded' | 'TotalCollectionsLimitExceeded' | 'TokenVariableDataLimitExceeded' | 'CollectionAdminCountExceeded' | 'CollectionLimitBoundsExceeded' | 'OwnerPermissionsCantBeReverted' | 'TransferNotAllowed' | 'AccountTokenLimitExceeded' | 'CollectionTokenLimitExceeded' | 'MetadataFlagFrozen' | 'TokenNotFound' | 'TokenValueTooLow' | 'ApprovedValueTooLow' | 'CantApproveMoreThanOwned' | 'AddressIsZero' | 'UnsupportedOperation';
+ readonly isNotSufficientFounds: boolean;
+ readonly type: 'CollectionNotFound' | 'MustBeTokenOwner' | 'NoPermission' | 'PublicMintingNotAllowed' | 'AddressNotInAllowlist' | 'CollectionNameLimitExceeded' | 'CollectionDescriptionLimitExceeded' | 'CollectionTokenPrefixLimitExceeded' | 'TotalCollectionsLimitExceeded' | 'TokenVariableDataLimitExceeded' | 'CollectionAdminCountExceeded' | 'CollectionLimitBoundsExceeded' | 'OwnerPermissionsCantBeReverted' | 'TransferNotAllowed' | 'AccountTokenLimitExceeded' | 'CollectionTokenLimitExceeded' | 'MetadataFlagFrozen' | 'TokenNotFound' | 'TokenValueTooLow' | 'ApprovedValueTooLow' | 'CantApproveMoreThanOwned' | 'AddressIsZero' | 'UnsupportedOperation' | 'NotSufficientFounds';
}
/** @name PalletCommonEvent */
@@ -1721,9 +1725,6 @@
readonly transactionVersion: u32;
readonly stateVersion: u8;
}
-
-/** @name UniqueRuntimeRuntime */
-export interface UniqueRuntimeRuntime extends Null {}
/** @name UpDataStructsAccessMode */
export interface UpDataStructsAccessMode extends Enum {
tests/src/limits.test.tsdiffbeforeafterboth--- a/tests/src/limits.test.ts
+++ b/tests/src/limits.test.ts
@@ -396,3 +396,51 @@
//expect(aliceBalanceAfterSponsoredTransaction1).to.be.lessThan(aliceBalanceBefore);
});
});
+
+describe.only('Effective collection limits', () => {
+ it('Test1', async () => {
+ await usingApi(async (api) => {
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+
+ {
+ const collection = await api.rpc.unique.collectionById(collectionId);
+ expect(collection.isSome).to.be.true;
+ const limits = collection.unwrap().limits;
+ expect(limits).to.be.any;
+
+ // Check that limits is undefined
+ expect(limits.accountTokenOwnershipLimit.isNone).to.be.true;
+ expect(limits.sponsoredDataSize.isNone).to.be.true;
+ expect(limits.sponsoredDataRateLimit.isNone).to.be.true;
+ expect(limits.tokenLimit.isNone).to.be.true;
+ expect(limits.sponsorTransferTimeout.isNone).to.be.true;
+ expect(limits.sponsorApproveTimeout.isNone).to.be.true;
+ expect(limits.ownerCanTransfer.isNone).to.be.true;
+ expect(limits.ownerCanDestroy.isNone).to.be.true;
+ expect(limits.transfersEnabled.isNone).to.be.true;
+ }
+
+ {
+ const limits = await api.rpc.unique.effectiveCollectionLimits(11111);
+ expect(limits.isNone).to.be.true;
+ }
+
+ {
+ const limitsOpt = await api.rpc.unique.effectiveCollectionLimits(collectionId);
+ expect(limitsOpt.isNone).to.be.false;
+ const limits = limitsOpt.unwrap();
+
+ console.log(limits);
+ expect(limits.accountTokenOwnershipLimit.isSome).to.be.true;
+ expect(limits.sponsoredDataSize.isSome).to.be.true;
+ expect(limits.sponsoredDataRateLimit.isSome).to.be.true;
+ expect(limits.tokenLimit.isSome).to.be.true;
+ expect(limits.sponsorTransferTimeout.isSome).to.be.true;
+ expect(limits.sponsorApproveTimeout.isSome).to.be.true;
+ expect(limits.ownerCanTransfer.isSome).to.be.true;
+ expect(limits.ownerCanDestroy.isSome).to.be.true;
+ expect(limits.transfersEnabled.isSome).to.be.true;
+ }
+ });
+ });
+});
\ No newline at end of file