git.delta.rocks / unique-network / refs/commits / 41b30206b8b0

difftreelog

build remove RMRK usage

Fahrrader2022-05-27parent: #7f246e9.patch.diff
in: master

6 files changed

modifiednode/cli/src/service.rsdiffbeforeafterboth
68use unique_runtime_common::types::{AuraId, RuntimeInstance, AccountId, Balance, Index, Hash, Block};68use unique_runtime_common::types::{AuraId, RuntimeInstance, AccountId, Balance, Index, Hash, Block};
6969
70// RMRK70// RMRK
71use up_data_structs::{71/* TODO free RMRK! use up_data_structs::{
72 RmrkCollectionInfo, RmrkInstanceInfo, RmrkResourceInfo, RmrkPropertyInfo, RmrkBaseInfo,72 RmrkCollectionInfo, RmrkInstanceInfo, RmrkResourceInfo, RmrkPropertyInfo, RmrkBaseInfo,
73 RmrkPartType, RmrkTheme,73 RmrkPartType, RmrkTheme,
74};74};*/
7575
76/// Unique native executor instance.76/// Unique native executor instance.
77#[cfg(feature = "unique-runtime")]77#[cfg(feature = "unique-runtime")]
353 + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>353 + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
354 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>354 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>
355 + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>355 + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>
356 + rmrk_rpc::RmrkApi<356 /* TODO free RMRK!
357 Block,357 + rmrk_rpc::RmrkApi<
358 AccountId,358 Block,
359 RmrkCollectionInfo<AccountId>,359 AccountId,
360 RmrkInstanceInfo<AccountId>,360 RmrkCollectionInfo<AccountId>,
361 RmrkResourceInfo,361 RmrkInstanceInfo<AccountId>,
362 RmrkPropertyInfo,362 RmrkResourceInfo,
363 RmrkBaseInfo<AccountId>,363 RmrkPropertyInfo,
364 RmrkPartType,364 RmrkBaseInfo<AccountId>,
365 RmrkTheme,365 RmrkPartType,
366 RmrkTheme,
366 > + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>367 >*/ + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>
367 + sp_api::Metadata<Block>368 + sp_api::Metadata<Block>
368 + sp_offchain::OffchainWorkerApi<Block>369 + sp_offchain::OffchainWorkerApi<Block>
369 + cumulus_primitives_core::CollectCollationInfo<Block>,370 + cumulus_primitives_core::CollectCollationInfo<Block>,
644 + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>645 + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
645 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>646 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>
646 + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>647 + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>
647 + rmrk_rpc::RmrkApi<648 /* TODO free RMRK!
648 Block,649 + rmrk_rpc::RmrkApi<
649 AccountId,650 Block,
650 RmrkCollectionInfo<AccountId>,651 AccountId,
651 RmrkInstanceInfo<AccountId>,652 RmrkCollectionInfo<AccountId>,
652 RmrkResourceInfo,653 RmrkInstanceInfo<AccountId>,
653 RmrkPropertyInfo,654 RmrkResourceInfo,
654 RmrkBaseInfo<AccountId>,655 RmrkPropertyInfo,
655 RmrkPartType,656 RmrkBaseInfo<AccountId>,
656 RmrkTheme,657 RmrkPartType,
658 RmrkTheme,
657 > + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>659 >*/ + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>
658 + sp_api::Metadata<Block>660 + sp_api::Metadata<Block>
659 + sp_offchain::OffchainWorkerApi<Block>661 + sp_offchain::OffchainWorkerApi<Block>
660 + cumulus_primitives_core::CollectCollationInfo<Block>662 + cumulus_primitives_core::CollectCollationInfo<Block>
787 + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>789 + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
788 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>790 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>
789 + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>791 + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>
790 + rmrk_rpc::RmrkApi<792 /* TODO free RMRK!
791 Block,793 + rmrk_rpc::RmrkApi<
792 AccountId,794 Block,
793 RmrkCollectionInfo<AccountId>,795 AccountId,
794 RmrkInstanceInfo<AccountId>,796 RmrkCollectionInfo<AccountId>,
795 RmrkResourceInfo,797 RmrkInstanceInfo<AccountId>,
796 RmrkPropertyInfo,798 RmrkResourceInfo,
797 RmrkBaseInfo<AccountId>,799 RmrkPropertyInfo,
798 RmrkPartType,800 RmrkBaseInfo<AccountId>,
799 RmrkTheme,801 RmrkPartType,
802 RmrkTheme,
800 > + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>803 >*/ + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>
801 + sp_api::Metadata<Block>804 + sp_api::Metadata<Block>
802 + sp_offchain::OffchainWorkerApi<Block>805 + sp_offchain::OffchainWorkerApi<Block>
803 + cumulus_primitives_core::CollectCollationInfo<Block>806 + cumulus_primitives_core::CollectCollationInfo<Block>
modifiednode/rpc/src/lib.rsdiffbeforeafterboth
44 Hash, AccountId, RuntimeInstance, Index, Block, BlockNumber, Balance,44 Hash, AccountId, RuntimeInstance, Index, Block, BlockNumber, Balance,
45};45};
46// RMRK46// RMRK
47use up_data_structs::{47/* TODO free RMRK! use up_data_structs::{
48 RmrkCollectionInfo, RmrkInstanceInfo, RmrkResourceInfo, RmrkPropertyInfo, RmrkBaseInfo,48 RmrkCollectionInfo, RmrkInstanceInfo, RmrkResourceInfo, RmrkPropertyInfo, RmrkBaseInfo,
49 RmrkPartType, RmrkTheme,49 RmrkPartType, RmrkTheme,
50};50};*/
5151
52/// Public io handler for exporting into other modules52/// Public io handler for exporting into other modules
53pub type IoHandler = jsonrpc_core::IoHandler<sc_rpc::Metadata>;53pub type IoHandler = jsonrpc_core::IoHandler<sc_rpc::Metadata>;
149 C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,149 C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,
150 C::Api: fp_rpc::ConvertTransactionRuntimeApi<Block>,150 C::Api: fp_rpc::ConvertTransactionRuntimeApi<Block>,
151 C::Api: up_rpc::UniqueApi<Block, <R as RuntimeInstance>::CrossAccountId, AccountId>,151 C::Api: up_rpc::UniqueApi<Block, <R as RuntimeInstance>::CrossAccountId, AccountId>,
152 C::Api: rmrk_rpc::RmrkApi<152 /* TODO free RMRK!
153 Block,153 C::Api: rmrk_rpc::RmrkApi<
154 AccountId,154 Block,
155 RmrkCollectionInfo<AccountId>,155 AccountId,
156 RmrkInstanceInfo<AccountId>,156 RmrkCollectionInfo<AccountId>,
157 RmrkResourceInfo,157 RmrkInstanceInfo<AccountId>,
158 RmrkPropertyInfo,158 RmrkResourceInfo,
159 RmrkBaseInfo<AccountId>,159 RmrkPropertyInfo,
160 RmrkPartType,160 RmrkBaseInfo<AccountId>,
161 RmrkTheme,161 RmrkPartType,
162 >,162 RmrkTheme,
163 >,*/
163 B: sc_client_api::Backend<Block> + Send + Sync + 'static,164 B: sc_client_api::Backend<Block> + Send + Sync + 'static,
164 B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,165 B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,
165 P: TransactionPool<Block = Block> + 'static,166 P: TransactionPool<Block = Block> + 'static,
233 // todo look into234 // todo look into
234 //let unique = Unique::new(client.clone());235 //let unique = Unique::new(client.clone());
235 io.extend_with(UniqueApi::to_delegate(Unique::new(client.clone())));236 io.extend_with(UniqueApi::to_delegate(Unique::new(client.clone())));
236 io.extend_with(RmrkApi::to_delegate(Unique::new(client.clone())));237 // TODO free RMRK! io.extend_with(RmrkApi::to_delegate(Unique::new(client.clone())));
237238
238 if let Some(filter_pool) = filter_pool {239 if let Some(filter_pool) = filter_pool {
239 io.extend_with(EthFilterApiServer::to_delegate(EthFilterApi::new(240 io.extend_with(EthFilterApiServer::to_delegate(EthFilterApi::new(
modifiedruntime/common/src/runtime_apis.rsdiffbeforeafterboth
126 }126 }
127 }127 }
128128
129 impl rmrk_rpc::RmrkApi<129 /*
130 Block,130 TODO free RMRK!
131 AccountId,131 impl rmrk_rpc::RmrkApi<
132 RmrkCollectionInfo<AccountId>,132 Block,
133 RmrkInstanceInfo<AccountId>,133 AccountId,
134 RmrkResourceInfo,134 RmrkCollectionInfo<AccountId>,
135 RmrkPropertyInfo,135 RmrkInstanceInfo<AccountId>,
136 RmrkBaseInfo<AccountId>,136 RmrkResourceInfo,
137 RmrkPartType,137 RmrkPropertyInfo,
138 RmrkTheme138 RmrkBaseInfo<AccountId>,
139 > for Runtime {139 RmrkPartType,
140 fn last_collection_idx() -> Result<RmrkCollectionId, DispatchError> {140 RmrkTheme
141 Ok(RmrkCore::last_collection_idx())141 > for Runtime {
142 }142 fn last_collection_idx() -> Result<RmrkCollectionId, DispatchError> {
143143 Ok(RmrkCore::last_collection_idx())
144 fn collection_by_id(collection_id: RmrkCollectionId) -> Result<Option<RmrkCollectionInfo<AccountId>>, DispatchError> {144 }
145 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, RmrkDecode, RmrkRebind}};145
146146 fn collection_by_id(collection_id: RmrkCollectionId) -> Result<Option<RmrkCollectionInfo<AccountId>>, DispatchError> {
147 let collection_id = CollectionId(collection_id);147 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, RmrkDecode, RmrkRebind}};
148 let collection = match RmrkCore::get_typed_nft_collection(collection_id, CollectionType::Regular) {148
149 Ok(c) => c,149 let collection_id = CollectionId(collection_id);
150 Err(_) => return Ok(None),150 let collection = match RmrkCore::get_typed_nft_collection(collection_id, CollectionType::Regular) {
151 };151 Ok(c) => c,
152152 Err(_) => return Ok(None),
153 let nfts_count = dispatch_unique_runtime!(collection_id.total_supply())?;153 };
154154
155 Ok(Some(RmrkCollectionInfo {155 let nfts_count = dispatch_unique_runtime!(collection_id.total_supply())?;
156 issuer: collection.owner.clone(),156
157 metadata: RmrkCore::get_collection_property(collection_id, RmrkProperty::Metadata)?.decode_or_default(),157 Ok(Some(RmrkCollectionInfo {
158 max: collection.limits.token_limit,158 issuer: collection.owner.clone(),
159 symbol: collection.token_prefix.rebind(),159 metadata: RmrkCore::get_collection_property(collection_id, RmrkProperty::Metadata)?.decode_or_default(),
160 nfts_count160 max: collection.limits.token_limit,
161 }))161 symbol: collection.token_prefix.rebind(),
162 }162 nfts_count
163163 }))
164 fn nft_by_id(collection_id: RmrkCollectionId, nft_by_id: RmrkNftId) -> Result<Option<RmrkInstanceInfo<AccountId>>, DispatchError> {164 }
165 use up_data_structs::mapping::TokenAddressMapping;165
166 use pallet_proxy_rmrk_core::{RmrkProperty, misc::RmrkDecode};166 fn nft_by_id(collection_id: RmrkCollectionId, nft_by_id: RmrkNftId) -> Result<Option<RmrkInstanceInfo<AccountId>>, DispatchError> {
167167 use up_data_structs::mapping::TokenAddressMapping;
168 let collection_id = CollectionId(collection_id);168 use pallet_proxy_rmrk_core::{RmrkProperty, misc::RmrkDecode};
169 let nft_id = TokenId(nft_by_id);169
170 if !RmrkCore::nft_exists(collection_id, nft_id) { return Ok(None); }170 let collection_id = CollectionId(collection_id);
171171 let nft_id = TokenId(nft_by_id);
172 let owner = match dispatch_unique_runtime!(collection_id.token_owner(nft_id))? {172 if !RmrkCore::nft_exists(collection_id, nft_id) { return Ok(None); }
173 Some(owner) => match <Runtime as pallet_common::Config>::CrossTokenAddressMapping::address_to_token(&owner) {173
174 Some((col, tok)) => RmrkAccountIdOrCollectionNftTuple::CollectionAndNftTuple(col.0, tok.0),174 let owner = match dispatch_unique_runtime!(collection_id.token_owner(nft_id))? {
175 None => RmrkAccountIdOrCollectionNftTuple::AccountId(owner.as_sub().clone())175 Some(owner) => match <Runtime as pallet_common::Config>::CrossTokenAddressMapping::address_to_token(&owner) {
176 },176 Some((col, tok)) => RmrkAccountIdOrCollectionNftTuple::CollectionAndNftTuple(col.0, tok.0),
177 None => return Ok(None)177 None => RmrkAccountIdOrCollectionNftTuple::AccountId(owner.as_sub().clone())
178 };178 },
179179 None => return Ok(None)
180 let allowance = pallet_nonfungible::Allowance::<Runtime>::get((collection_id, nft_id));180 };
181181
182 Ok(Some(RmrkInstanceInfo {182 let allowance = pallet_nonfungible::Allowance::<Runtime>::get((collection_id, nft_id));
183 owner: owner,183
184 royalty: RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::RoyaltyInfo)?.decode_or_default(),184 Ok(Some(RmrkInstanceInfo {
185 metadata: RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::Metadata)?.decode_or_default(),185 owner: owner,
186 equipped: RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::Equipped)?.decode_or_default(),186 royalty: RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::RoyaltyInfo)?.decode_or_default(),
187 pending: allowance.is_some(),187 metadata: RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::Metadata)?.decode_or_default(),
188 }))188 equipped: RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::Equipped)?.decode_or_default(),
189 }189 pending: allowance.is_some(),
190190 }))
191 fn account_tokens(account_id: AccountId, collection_id: RmrkCollectionId) -> Result<Vec<RmrkNftId>, DispatchError> {191 }
192 use pallet_proxy_rmrk_core::misc::CollectionType;192
193193 fn account_tokens(account_id: AccountId, collection_id: RmrkCollectionId) -> Result<Vec<RmrkNftId>, DispatchError> {
194 let cross_account_id = CrossAccountId::from_sub(account_id);194 use pallet_proxy_rmrk_core::misc::CollectionType;
195 let collection_id = CollectionId(collection_id);195
196 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Regular).is_err() { return Ok(Vec::new()); }196 let cross_account_id = CrossAccountId::from_sub(account_id);
197197 let collection_id = CollectionId(collection_id);
198 Ok(198 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Regular).is_err() { return Ok(Vec::new()); }
199 dispatch_unique_runtime!(collection_id.account_tokens(cross_account_id))?199
200 .into_iter()200 Ok(
201 .map(|token| token.0)201 dispatch_unique_runtime!(collection_id.account_tokens(cross_account_id))?
202 .collect()202 .into_iter()
203 )203 .map(|token| token.0)
204 }204 .collect()
205205 )
206 fn nft_children(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkNftChild>, DispatchError> {206 }
207 let collection_id = CollectionId(collection_id);207
208 let nft_id = TokenId(nft_id);208 fn nft_children(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkNftChild>, DispatchError> {
209 if !RmrkCore::nft_exists(collection_id, nft_id) { return Ok(Vec::new()); }209 let collection_id = CollectionId(collection_id);
210210 let nft_id = TokenId(nft_id);
211 Ok(211 if !RmrkCore::nft_exists(collection_id, nft_id) { return Ok(Vec::new()); }
212 pallet_nonfungible::TokenChildren::<Runtime>::iter_prefix((collection_id, nft_id))212
213 .filter_map(|(child_id, is_child)|213 Ok(
214 match is_child {214 pallet_nonfungible::TokenChildren::<Runtime>::iter_prefix((collection_id, nft_id))
215 true => Some(RmrkNftChild {215 .filter_map(|(child_id, is_child)|
216 collection_id: child_id.0.0,216 match is_child {
217 nft_id: child_id.1.0,217 true => Some(RmrkNftChild {
218 }),218 collection_id: child_id.0.0,
219 false => None,219 nft_id: child_id.1.0,
220 }220 }),
221 ).collect()221 false => None,
222 )222 }
223 }223 ).collect()
224224 )
225 fn collection_properties(collection_id: RmrkCollectionId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {225 }
226 use pallet_proxy_rmrk_core::misc::CollectionType;226
227227 fn collection_properties(collection_id: RmrkCollectionId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {
228 let collection_id = CollectionId(collection_id);228 use pallet_proxy_rmrk_core::misc::CollectionType;
229 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Regular).is_err() {229
230 return Ok(Vec::new());230 let collection_id = CollectionId(collection_id);
231 }231 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Regular).is_err() {
232232 return Ok(Vec::new());
233 let properties = RmrkCore::filter_user_properties(233 }
234 collection_id,234
235 /* token_id = */ None,235 let properties = RmrkCore::filter_user_properties(
236 filter_keys,236 collection_id,
237 |key, value| RmrkPropertyInfo {237 /* token_id = */ None,
238 key,238 filter_keys,
239 value239 |key, value| RmrkPropertyInfo {
240 }240 key,
241 )?;241 value
242242 }
243 Ok(properties)243 )?;
244 }244
245245 Ok(properties)
246 fn nft_properties(collection_id: RmrkCollectionId, nft_id: RmrkNftId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {246 }
247 use pallet_proxy_rmrk_core::misc::NftType;247
248248 fn nft_properties(collection_id: RmrkCollectionId, nft_id: RmrkNftId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {
249 let collection_id = CollectionId(collection_id);249 use pallet_proxy_rmrk_core::misc::NftType;
250 let token_id = TokenId(nft_id);250
251251 let collection_id = CollectionId(collection_id);
252 if RmrkCore::ensure_nft_type(collection_id, token_id, NftType::Regular).is_err() {252 let token_id = TokenId(nft_id);
253 return Ok(Vec::new());253
254 }254 if RmrkCore::ensure_nft_type(collection_id, token_id, NftType::Regular).is_err() {
255255 return Ok(Vec::new());
256 let properties = RmrkCore::filter_user_properties(256 }
257 collection_id,257
258 Some(token_id),258 let properties = RmrkCore::filter_user_properties(
259 filter_keys,259 collection_id,
260 |key, value| RmrkPropertyInfo {260 Some(token_id),
261 key,261 filter_keys,
262 value262 |key, value| RmrkPropertyInfo {
263 }263 key,
264 )?;264 value
265265 }
266 Ok(properties)266 )?;
267 }267
268268 Ok(properties)
269 fn nft_resources(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkResourceInfo>, DispatchError> {269 }
270 use frame_support::BoundedVec;270
271 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, NftType, RmrkDecode}};271 fn nft_resources(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkResourceInfo>, DispatchError> {
272272 use frame_support::BoundedVec;
273 let collection_id = CollectionId(collection_id);273 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, NftType, RmrkDecode}};
274 if !RmrkCore::collection_exists(collection_id) { return Ok(Vec::new()); } // todo make sure the collection type doesn't matter274
275275 let collection_id = CollectionId(collection_id);
276 let nft_id = TokenId(nft_id);276 if !RmrkCore::collection_exists(collection_id) { return Ok(Vec::new()); } // todo make sure the collection type doesn't matter
277 if RmrkCore::ensure_nft_type(collection_id, nft_id, NftType::Resource).is_err() { return Ok(Vec::new()); }277
278278 let nft_id = TokenId(nft_id);
279 let resource_collection_id: CollectionId = RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::ResourceCollection)279 if RmrkCore::ensure_nft_type(collection_id, nft_id, NftType::Resource).is_err() { return Ok(Vec::new()); }
280 .unwrap()280
281 .decode_or_default();281 let resource_collection_id: CollectionId = RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::ResourceCollection)
282 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Resource).is_err() { return Ok(Vec::new()); }282 .unwrap()
283283 .decode_or_default();
284 let resources = pallet_nonfungible::TokenProperties::<Runtime>::iter_prefix((resource_collection_id,))284 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Resource).is_err() { return Ok(Vec::new()); }
285 .filter_map(|(resource_id, properties)| Some(RmrkResourceInfo {285
286 id: BoundedVec::default(), // todo ResourceId property286 let resources = pallet_nonfungible::TokenProperties::<Runtime>::iter_prefix((resource_collection_id,))
287 pending: RmrkCore::get_nft_property(resource_collection_id, resource_id, RmrkProperty::PendingResourceAccept).unwrap().decode_or_default(),287 .filter_map(|(resource_id, properties)| Some(RmrkResourceInfo {
288 pending_removal: RmrkCore::get_nft_property(resource_collection_id, resource_id, RmrkProperty::PendingResourceRemoval).unwrap().decode_or_default(),288 id: BoundedVec::default(), // todo ResourceId property
289 resource: RmrkCore::get_nft_property(resource_collection_id, resource_id, RmrkProperty::ResourceType).unwrap().decode_or_default(),/* {289 pending: RmrkCore::get_nft_property(resource_collection_id, resource_id, RmrkProperty::PendingResourceAccept).unwrap().decode_or_default(),
290 RmrkResourceTypes::Basic(resource) => RmrkResourceTypes::Basic(),/*(RmrkBasicResource {290 pending_removal: RmrkCore::get_nft_property(resource_collection_id, resource_id, RmrkProperty::PendingResourceRemoval).unwrap().decode_or_default(),
291 src: RmrkCore::get_nft_property_inner(properties, RmrkProperty::Src).unwrap().decode_or_default(),291 resource: RmrkCore::get_nft_property(resource_collection_id, resource_id, RmrkProperty::ResourceType).unwrap().decode_or_default(),/* {
292 metadata: RmrkCore::get_nft_property_inner(properties, RmrkProperty::Metadata).unwrap().decode_or_default(),292 RmrkResourceTypes::Basic(resource) => RmrkResourceTypes::Basic(),/*(RmrkBasicResource {
293 license: RmrkCore::get_nft_property_inner(properties, RmrkProperty::License).unwrap().decode_or_default(),293 src: RmrkCore::get_nft_property_inner(properties, RmrkProperty::Src).unwrap().decode_or_default(),
294 thumb: RmrkCore::get_nft_property_inner(properties, RmrkProperty::Thumb).unwrap().decode_or_default(),294 metadata: RmrkCore::get_nft_property_inner(properties, RmrkProperty::Metadata).unwrap().decode_or_default(),
295 },*///BasicResource<BoundedString>)295 license: RmrkCore::get_nft_property_inner(properties, RmrkProperty::License).unwrap().decode_or_default(),
296 _ => todo!(), //RmrkResourceTypes::Composable(ComposableResource<BoundedString, BoundedParts>),296 thumb: RmrkCore::get_nft_property_inner(properties, RmrkProperty::Thumb).unwrap().decode_or_default(),
297 //RmrkResourceTypes::Slot(SlotResource<BoundedString>),297 },*///BasicResource<BoundedString>)
298 },*/298 _ => todo!(), //RmrkResourceTypes::Composable(ComposableResource<BoundedString, BoundedParts>),
299 }))299 //RmrkResourceTypes::Slot(SlotResource<BoundedString>),
300 .collect();300 },*/
301301 }))
302 Ok(resources)302 .collect();
303 }303
304304 Ok(resources)
305 fn nft_resource_priorities(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkResourceId>, DispatchError> {305 }
306 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, NftType, RmrkDecode}};306
307307 fn nft_resource_priorities(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkResourceId>, DispatchError> {
308 let collection_id = CollectionId(collection_id);308 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, NftType, RmrkDecode}};
309 if !RmrkCore::collection_exists(collection_id) { return Ok(Vec::new()); } // todo ensure the collection type doesn't matter309
310310 let collection_id = CollectionId(collection_id);
311 let nft_id = TokenId(nft_id);311 if !RmrkCore::collection_exists(collection_id) { return Ok(Vec::new()); } // todo ensure the collection type doesn't matter
312 if RmrkCore::ensure_nft_type(collection_id, nft_id, NftType::Resource).is_err() { return Ok(Vec::new()); }312
313313 let nft_id = TokenId(nft_id);
314 /*let resource_collection_id: CollectionId = RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::ResourceCollection)314 if RmrkCore::ensure_nft_type(collection_id, nft_id, NftType::Resource).is_err() { return Ok(Vec::new()); }
315 .unwrap()315
316 .decode_or_default();316 /*let resource_collection_id: CollectionId = RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::ResourceCollection)
317 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Resource).is_err() { return Ok(Vec::new()); }317 .unwrap()
318318 .decode_or_default();
319 let resources = pallet_nonfungible::TokenProperties::<Runtime>::iter_prefix((resource_collection_id,))319 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Resource).is_err() { return Ok(Vec::new()); }
320 .filter_map(|(resource_id, properties)| Some((320
321 resource_id, // ResourceId property321 let resources = pallet_nonfungible::TokenProperties::<Runtime>::iter_prefix((resource_collection_id,))
322 RmrkCore::get_nft_property(resource_collection_id, resource_id, RmrkProperty::Priority).unwrap().decode_or_default(),322 .filter_map(|(resource_id, properties)| Some((
323 )))323 resource_id, // ResourceId property
324 .collect()324 RmrkCore::get_nft_property(resource_collection_id, resource_id, RmrkProperty::Priority).unwrap().decode_or_default(),
325 .sort_by_key(|(_, index)| *index)325 )))
326 .into_iter().map(|(resource_id, _)| resource_id)*/326 .collect()
327 let priorities = RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::ResourcePriorities)?.decode_or_default();327 .sort_by_key(|(_, index)| *index)
328328 .into_iter().map(|(resource_id, _)| resource_id)*/
329 Ok(priorities)329 let priorities = RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::ResourcePriorities)?.decode_or_default();
330 }330
331331 Ok(priorities)
332 fn base(base_id: RmrkBaseId) -> Result<Option<RmrkBaseInfo<AccountId>>, DispatchError> {332 }
333 use pallet_proxy_rmrk_core::{333
334 RmrkProperty, misc::{CollectionType, RmrkDecode, RmrkRebind},334 fn base(base_id: RmrkBaseId) -> Result<Option<RmrkBaseInfo<AccountId>>, DispatchError> {
335 };335 use pallet_proxy_rmrk_core::{
336336 RmrkProperty, misc::{CollectionType, RmrkDecode, RmrkRebind},
337 let collection_id = CollectionId(base_id);337 };
338 let collection = match RmrkCore::get_typed_nft_collection(collection_id, CollectionType::Base) {338
339 Ok(c) => c,339 let collection_id = CollectionId(base_id);
340 Err(_) => return Ok(None),340 let collection = match RmrkCore::get_typed_nft_collection(collection_id, CollectionType::Base) {
341 };341 Ok(c) => c,
342342 Err(_) => return Ok(None),
343 Ok(Some(RmrkBaseInfo {343 };
344 issuer: collection.owner.clone(),344
345 base_type: RmrkCore::get_collection_property(collection_id, RmrkProperty::BaseType)?.decode_or_default(),345 Ok(Some(RmrkBaseInfo {
346 symbol: collection.token_prefix.rebind(),346 issuer: collection.owner.clone(),
347 }))347 base_type: RmrkCore::get_collection_property(collection_id, RmrkProperty::BaseType)?.decode_or_default(),
348 }348 symbol: collection.token_prefix.rebind(),
349349 }))
350 fn base_parts(base_id: RmrkBaseId) -> Result<Vec<RmrkPartType>, DispatchError> {350 }
351 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, NftType, RmrkDecode}};351
352352 fn base_parts(base_id: RmrkBaseId) -> Result<Vec<RmrkPartType>, DispatchError> {
353 let collection_id = CollectionId(base_id);353 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, NftType, RmrkDecode}};
354 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Base).is_err() { return Ok(Vec::new()); }354
355355 let collection_id = CollectionId(base_id);
356 let parts = dispatch_unique_runtime!(collection_id.collection_tokens())?356 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Base).is_err() { return Ok(Vec::new()); }
357 .into_iter()357
358 .filter_map(|token_id| {358 let parts = dispatch_unique_runtime!(collection_id.collection_tokens())?
359 let nft_type = RmrkCore::get_nft_type(collection_id, token_id).ok()?;359 .into_iter()
360360 .filter_map(|token_id| {
361 match nft_type {361 let nft_type = RmrkCore::get_nft_type(collection_id, token_id).ok()?;
362 NftType::FixedPart => Some(RmrkPartType::FixedPart(RmrkFixedPart {362
363 id: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ExternalPartId).ok()?.decode_or_default(),363 match nft_type {
364 src: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::Src).ok()?.decode_or_default(),364 NftType::FixedPart => Some(RmrkPartType::FixedPart(RmrkFixedPart {
365 z: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ZIndex).ok()?.decode_or_default(),365 id: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ExternalPartId).ok()?.decode_or_default(),
366 })),366 src: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::Src).ok()?.decode_or_default(),
367 NftType::SlotPart => Some(RmrkPartType::SlotPart(RmrkSlotPart {367 z: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ZIndex).ok()?.decode_or_default(),
368 id: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ExternalPartId).ok()?.decode_or_default(),368 })),
369 src: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::Src).ok()?.decode_or_default(),369 NftType::SlotPart => Some(RmrkPartType::SlotPart(RmrkSlotPart {
370 z: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ZIndex).ok()?.decode_or_default(),370 id: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ExternalPartId).ok()?.decode_or_default(),
371 equippable: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::EquippableList).ok()?.decode_or_default(),371 src: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::Src).ok()?.decode_or_default(),
372 })),372 z: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ZIndex).ok()?.decode_or_default(),
373 _ => None373 equippable: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::EquippableList).ok()?.decode_or_default(),
374 }374 })),
375 })375 _ => None
376 .collect();376 }
377377 })
378 Ok(parts)378 .collect();
379 }379
380380 Ok(parts)
381 fn theme_names(base_id: RmrkBaseId) -> Result<Vec<RmrkThemeName>, DispatchError> {381 }
382 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, RmrkDecode}};382
383383 fn theme_names(base_id: RmrkBaseId) -> Result<Vec<RmrkThemeName>, DispatchError> {
384 let collection_id = CollectionId(base_id);384 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, RmrkDecode}};
385 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Base).is_err() {385
386 return Ok(Vec::new());386 let collection_id = CollectionId(base_id);
387 }387 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Base).is_err() {
388388 return Ok(Vec::new());
389 let theme_names = dispatch_unique_runtime!(collection_id.collection_tokens())?389 }
390 .iter()390
391 .filter_map(|token_id| {391 let theme_names = dispatch_unique_runtime!(collection_id.collection_tokens())?
392 let nft_type = RmrkCore::get_nft_type(collection_id, *token_id).unwrap();392 .iter()
393393 .filter_map(|token_id| {
394 match nft_type {394 let nft_type = RmrkCore::get_nft_type(collection_id, *token_id).unwrap();
395 Theme => Some(395
396 RmrkCore::get_nft_property(collection_id, *token_id, RmrkProperty::ThemeName).unwrap().decode_or_default()396 match nft_type {
397 ),397 Theme => Some(
398 _ => None398 RmrkCore::get_nft_property(collection_id, *token_id, RmrkProperty::ThemeName).unwrap().decode_or_default()
399 }399 ),
400 })400 _ => None
401 .collect();401 }
402402 })
403 Ok(theme_names)403 .collect();
404 }404
405405 Ok(theme_names)
406 fn theme(base_id: RmrkBaseId, theme_name: RmrkThemeName, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Option<RmrkTheme>, DispatchError> {406 }
407 use pallet_proxy_rmrk_core::{407
408 RmrkProperty,408 fn theme(base_id: RmrkBaseId, theme_name: RmrkThemeName, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Option<RmrkTheme>, DispatchError> {
409 misc::{CollectionType, NftType, RmrkDecode}409 use pallet_proxy_rmrk_core::{
410 };410 RmrkProperty,
411411 misc::{CollectionType, NftType, RmrkDecode}
412 let collection_id = CollectionId(base_id);412 };
413 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Base).is_err() {413
414 return Ok(None);414 let collection_id = CollectionId(base_id);
415 }415 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Base).is_err() {
416416 return Ok(None);
417 let theme_info = dispatch_unique_runtime!(collection_id.collection_tokens())?417 }
418 .into_iter()418
419 .find_map(|token_id| {419 let theme_info = dispatch_unique_runtime!(collection_id.collection_tokens())?
420 RmrkCore::ensure_nft_type(collection_id, token_id, NftType::Theme).ok()?;420 .into_iter()
421421 .find_map(|token_id| {
422 let name: RmrkString = RmrkCore::get_nft_property(422 RmrkCore::ensure_nft_type(collection_id, token_id, NftType::Theme).ok()?;
423 collection_id, token_id, RmrkProperty::ThemeName423
424 ).ok()?.decode_or_default();424 let name: RmrkString = RmrkCore::get_nft_property(
425425 collection_id, token_id, RmrkProperty::ThemeName
426 if name == theme_name {426 ).ok()?.decode_or_default();
427 Some((name, token_id))427
428 } else {428 if name == theme_name {
429 None429 Some((name, token_id))
430 }430 } else {
431 });431 None
432432 }
433 let (name, theme_id) = match theme_info {433 });
434 Some((name, theme_id)) => (name, theme_id),434
435 None => return Ok(None)435 let (name, theme_id) = match theme_info {
436 };436 Some((name, theme_id)) => (name, theme_id),
437437 None => return Ok(None)
438 let properties = RmrkCore::filter_user_properties(438 };
439 collection_id,439
440 Some(theme_id),440 let properties = RmrkCore::filter_user_properties(
441 filter_keys,441 collection_id,
442 |key, value| RmrkThemeProperty {442 Some(theme_id),
443 key,443 filter_keys,
444 value444 |key, value| RmrkThemeProperty {
445 }445 key,
446 )?;446 value
447447 }
448 let inherit = RmrkCore::get_nft_property(448 )?;
449 collection_id,449
450 theme_id,450 let inherit = RmrkCore::get_nft_property(
451 RmrkProperty::ThemeInherit451 collection_id,
452 )?.decode_or_default();452 theme_id,
453453 RmrkProperty::ThemeInherit
454 let theme = RmrkTheme {454 )?.decode_or_default();
455 name,455
456 properties,456 let theme = RmrkTheme {
457 inherit,457 name,
458 };458 properties,
459459 inherit,
460 Ok(Some(theme))460 };
461 }461
462 }462 Ok(Some(theme))
463 }
464 }*/
463465
464 impl sp_api::Core<Block> for Runtime {466 impl sp_api::Core<Block> for Runtime {
465 fn version() -> RuntimeVersion {467 fn version() -> RuntimeVersion {
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
903 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;903 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;
904}904}
905905
906impl pallet_proxy_rmrk_core::Config for Runtime {906/*
907 type Event = Event;907TODO free RMRK!
908}908impl pallet_proxy_rmrk_core::Config for Runtime {
909909 type Event = Event;
910impl pallet_proxy_rmrk_equip::Config for Runtime {910}
911 type Event = Event;911
912}912impl pallet_proxy_rmrk_equip::Config for Runtime {
913 type Event = Event;
914}*/
913915
914impl pallet_unique::Config for Runtime {916impl pallet_unique::Config for Runtime {
915 type Event = Event;917 type Event = Event;
1032 Refungible: pallet_refungible::{Pallet, Storage} = 68,1034 Refungible: pallet_refungible::{Pallet, Storage} = 68,
1033 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1035 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
1034 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1036 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,
1035 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,1037 /* TODO free RMRK!
1036 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,1038 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,
1039 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,
1040 */
10371041
1038 // Frontier1042 // Frontier
1039 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1043 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,
modifiedruntime/quartz/src/lib.rsdiffbeforeafterboth
887impl pallet_nonfungible::Config for Runtime {887impl pallet_nonfungible::Config for Runtime {
888 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;888 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;
889}889}
890890/* TODO free RMRK!
891impl pallet_proxy_rmrk_core::Config for Runtime {891impl pallet_proxy_rmrk_core::Config for Runtime {
892 type Event = Event;892 type Event = Event;
893}893}
894894
895impl pallet_proxy_rmrk_equip::Config for Runtime {895impl pallet_proxy_rmrk_equip::Config for Runtime {
896 type Event = Event;896 type Event = Event;
897}897}*/
898898
899impl pallet_unique::Config for Runtime {899impl pallet_unique::Config for Runtime {
900 type Event = Event;900 type Event = Event;
1017 Refungible: pallet_refungible::{Pallet, Storage} = 68,1017 Refungible: pallet_refungible::{Pallet, Storage} = 68,
1018 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1018 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
1019 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1019 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,
1020 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,1020 /* TODO free RMRK!
1021 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,1021 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,
1022 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,*/
10221023
1023 // Frontier1024 // Frontier
1024 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1025 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,
modifiedruntime/unique/src/lib.rsdiffbeforeafterboth
892impl pallet_nonfungible::Config for Runtime {892impl pallet_nonfungible::Config for Runtime {
893 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;893 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;
894}894}
895895/* TODO free RMRK!
896impl pallet_proxy_rmrk_core::Config for Runtime {896impl pallet_proxy_rmrk_core::Config for Runtime {
897 type Event = Event;897 type Event = Event;
898}898}
899899
900impl pallet_proxy_rmrk_equip::Config for Runtime {900impl pallet_proxy_rmrk_equip::Config for Runtime {
901 type Event = Event;901 type Event = Event;
902}902}*/
903903
904impl pallet_unique::Config for Runtime {904impl pallet_unique::Config for Runtime {
905 type Event = Event;905 type Event = Event;
1022 Refungible: pallet_refungible::{Pallet, Storage} = 68,1022 Refungible: pallet_refungible::{Pallet, Storage} = 68,
1023 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1023 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
1024 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1024 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,
1025 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,1025 /* TODO free RMRK!
1026 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,1026 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,
1027 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,*/
10271028
1028 // Frontier1029 // Frontier
1029 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1030 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,