git.delta.rocks / unique-network / refs/commits / 16474c6279e3

difftreelog

build(rmrk) rmrk freed

Fahrrader2022-05-31parent: #c557492.patch.diff
in: master

8 files changed

modifiednode/cli/src/service.rsdiffbeforeafterboth
66use unique_runtime_common::types::{AuraId, RuntimeInstance, AccountId, Balance, Index, Hash, Block};66use unique_runtime_common::types::{AuraId, RuntimeInstance, AccountId, Balance, Index, Hash, Block};
6767
68// RMRK68// RMRK
69/* TODO free RMRK! use up_data_structs::{69use up_data_structs::{
70 RmrkCollectionInfo, RmrkInstanceInfo, RmrkResourceInfo, RmrkPropertyInfo, RmrkBaseInfo,70 RmrkCollectionInfo, RmrkInstanceInfo, RmrkResourceInfo, RmrkPropertyInfo, RmrkBaseInfo,
71 RmrkPartType, RmrkTheme,71 RmrkPartType, RmrkTheme,
72};*/72};
7373
74/// Unique native executor instance.74/// Unique native executor instance.
75#[cfg(feature = "unique-runtime")]75#[cfg(feature = "unique-runtime")]
354 + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>354 + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
355 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>355 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>
356 + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>356 + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>
357 /* TODO free RMRK!357 + rmrk_rpc::RmrkApi<
358 + rmrk_rpc::RmrkApi<358 Block,
359 Block,359 AccountId,
360 AccountId,360 RmrkCollectionInfo<AccountId>,
361 RmrkCollectionInfo<AccountId>,361 RmrkInstanceInfo<AccountId>,
362 RmrkInstanceInfo<AccountId>,362 RmrkResourceInfo,
363 RmrkResourceInfo,363 RmrkPropertyInfo,
364 RmrkPropertyInfo,364 RmrkBaseInfo<AccountId>,
365 RmrkBaseInfo<AccountId>,365 RmrkPartType,
366 RmrkPartType,366 RmrkTheme,
367 RmrkTheme,367 >
368 >*/
369 + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>368 + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>
370 + sp_api::Metadata<Block>369 + sp_api::Metadata<Block>
371 + sp_offchain::OffchainWorkerApi<Block>370 + sp_offchain::OffchainWorkerApi<Block>
661 + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>660 + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
662 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>661 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>
663 + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>662 + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>
664 /* TODO free RMRK!663 + rmrk_rpc::RmrkApi<
665 + rmrk_rpc::RmrkApi<664 Block,
666 Block,665 AccountId,
667 AccountId,666 RmrkCollectionInfo<AccountId>,
668 RmrkCollectionInfo<AccountId>,667 RmrkInstanceInfo<AccountId>,
669 RmrkInstanceInfo<AccountId>,668 RmrkResourceInfo,
670 RmrkResourceInfo,669 RmrkPropertyInfo,
671 RmrkPropertyInfo,670 RmrkBaseInfo<AccountId>,
672 RmrkBaseInfo<AccountId>,671 RmrkPartType,
673 RmrkPartType,672 RmrkTheme,
674 RmrkTheme,673 >
675 >*/
676 + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>674 + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>
677 + sp_api::Metadata<Block>675 + sp_api::Metadata<Block>
678 + sp_offchain::OffchainWorkerApi<Block>676 + sp_offchain::OffchainWorkerApi<Block>
807 + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>805 + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
808 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>806 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>
809 + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>807 + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>
810 /* TODO free RMRK!808 + rmrk_rpc::RmrkApi<
811 + rmrk_rpc::RmrkApi<809 Block,
812 Block,810 AccountId,
813 AccountId,811 RmrkCollectionInfo<AccountId>,
814 RmrkCollectionInfo<AccountId>,812 RmrkInstanceInfo<AccountId>,
815 RmrkInstanceInfo<AccountId>,813 RmrkResourceInfo,
816 RmrkResourceInfo,814 RmrkPropertyInfo,
817 RmrkPropertyInfo,815 RmrkBaseInfo<AccountId>,
818 RmrkBaseInfo<AccountId>,816 RmrkPartType,
819 RmrkPartType,817 RmrkTheme,
820 RmrkTheme,818 >
821 >*/
822 + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>819 + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>
823 + sp_api::Metadata<Block>820 + sp_api::Metadata<Block>
824 + sp_offchain::OffchainWorkerApi<Block>821 + sp_offchain::OffchainWorkerApi<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
47/* TODO free RMRK! use up_data_structs::{47use 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/// Extra dependencies for GRANDPA52/// Extra dependencies for GRANDPA
53pub struct GrandpaDeps<B> {53pub struct GrandpaDeps<B> {
146 C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,146 C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,
147 C::Api: fp_rpc::ConvertTransactionRuntimeApi<Block>,147 C::Api: fp_rpc::ConvertTransactionRuntimeApi<Block>,
148 C::Api: up_rpc::UniqueApi<Block, <R as RuntimeInstance>::CrossAccountId, AccountId>,148 C::Api: up_rpc::UniqueApi<Block, <R as RuntimeInstance>::CrossAccountId, AccountId>,
149 /* TODO free RMRK!149 C::Api: rmrk_rpc::RmrkApi<
150 C::Api: rmrk_rpc::RmrkApi<150 Block,
151 Block,151 AccountId,
152 AccountId,152 RmrkCollectionInfo<AccountId>,
153 RmrkCollectionInfo<AccountId>,153 RmrkInstanceInfo<AccountId>,
154 RmrkInstanceInfo<AccountId>,154 RmrkResourceInfo,
155 RmrkResourceInfo,155 RmrkPropertyInfo,
156 RmrkPropertyInfo,156 RmrkBaseInfo<AccountId>,
157 RmrkBaseInfo<AccountId>,157 RmrkPartType,
158 RmrkPartType,158 RmrkTheme,
159 RmrkTheme,159 >,
160 >,*/
161 B: sc_client_api::Backend<Block> + Send + Sync + 'static,160 B: sc_client_api::Backend<Block> + Send + Sync + 'static,
162 B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,161 B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,
163 P: TransactionPool<Block = Block> + 'static,162 P: TransactionPool<Block = Block> + 'static,
223 .into_rpc(),222 .into_rpc(),
224 )?;223 )?;
225224
226 // todo look into
227 //let unique = Unique::new(client.clone());
228 io.merge(Unique::new(client.clone()).into_rpc())?;225 io.merge(Unique::new(client.clone()).into_rpc())?;
229 // TODO free RMRK! io.extend_with(RmrkApi::to_delegate(Unique::new(client.clone())));226 // TODO RMRK
230227
231 if let Some(filter_pool) = filter_pool {228 if let Some(filter_pool) = filter_pool {
232 io.merge(229 io.merge(
modifiedruntime/common/src/runtime_apis.rsdiffbeforeafterboth
128 }128 }
129 }129 }
130130
131 /*131 impl rmrk_rpc::RmrkApi<
132 TODO free RMRK!132 Block,
133 impl rmrk_rpc::RmrkApi<133 AccountId,
134 Block,134 RmrkCollectionInfo<AccountId>,
135 AccountId,135 RmrkInstanceInfo<AccountId>,
136 RmrkCollectionInfo<AccountId>,136 RmrkResourceInfo,
137 RmrkInstanceInfo<AccountId>,137 RmrkPropertyInfo,
138 RmrkResourceInfo,138 RmrkBaseInfo<AccountId>,
139 RmrkPropertyInfo,139 RmrkPartType,
140 RmrkBaseInfo<AccountId>,140 RmrkTheme
141 RmrkPartType,141 > for Runtime {
142 RmrkTheme142 fn last_collection_idx() -> Result<RmrkCollectionId, DispatchError> {
143 > for Runtime {143 Ok(RmrkCore::last_collection_idx())
144 fn last_collection_idx() -> Result<RmrkCollectionId, DispatchError> {144 }
145 Ok(RmrkCore::last_collection_idx())145
146 }146 fn collection_by_id(collection_id: RmrkCollectionId) -> Result<Option<RmrkCollectionInfo<AccountId>>, DispatchError> {
147147 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, RmrkDecode, RmrkRebind}};
148 fn collection_by_id(collection_id: RmrkCollectionId) -> Result<Option<RmrkCollectionInfo<AccountId>>, DispatchError> {148
149 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, RmrkDecode, RmrkRebind}};149 let collection_id = CollectionId(collection_id);
150150 let collection = match RmrkCore::get_typed_nft_collection(collection_id, CollectionType::Regular) {
151 let collection_id = CollectionId(collection_id);151 Ok(c) => c,
152 let collection = match RmrkCore::get_typed_nft_collection(collection_id, CollectionType::Regular) {152 Err(_) => return Ok(None),
153 Ok(c) => c,153 };
154 Err(_) => return Ok(None),154
155 };155 let nfts_count = dispatch_unique_runtime!(collection_id.total_supply())?;
156156
157 let nfts_count = dispatch_unique_runtime!(collection_id.total_supply())?;157 Ok(Some(RmrkCollectionInfo {
158158 issuer: collection.owner.clone(),
159 Ok(Some(RmrkCollectionInfo {159 metadata: RmrkCore::get_collection_property(collection_id, RmrkProperty::Metadata)?.decode_or_default(),
160 issuer: collection.owner.clone(),160 max: collection.limits.token_limit,
161 metadata: RmrkCore::get_collection_property(collection_id, RmrkProperty::Metadata)?.decode_or_default(),161 symbol: collection.token_prefix.rebind(),
162 max: collection.limits.token_limit,162 nfts_count
163 symbol: collection.token_prefix.rebind(),163 }))
164 nfts_count164 }
165 }))165
166 }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 fn nft_by_id(collection_id: RmrkCollectionId, nft_by_id: RmrkNftId) -> Result<Option<RmrkInstanceInfo<AccountId>>, DispatchError> {168 use pallet_proxy_rmrk_core::{RmrkProperty, misc::RmrkDecode};
169 use up_data_structs::mapping::TokenAddressMapping;169
170 use pallet_proxy_rmrk_core::{RmrkProperty, misc::RmrkDecode};170 let collection_id = CollectionId(collection_id);
171171 let nft_id = TokenId(nft_by_id);
172 let collection_id = CollectionId(collection_id);172 if !RmrkCore::nft_exists(collection_id, nft_id) { return Ok(None); }
173 let nft_id = TokenId(nft_by_id);173
174 if !RmrkCore::nft_exists(collection_id, nft_id) { return Ok(None); }174 let owner = match dispatch_unique_runtime!(collection_id.token_owner(nft_id))? {
175175 Some(owner) => match <Runtime as pallet_common::Config>::CrossTokenAddressMapping::address_to_token(&owner) {
176 let owner = match dispatch_unique_runtime!(collection_id.token_owner(nft_id))? {176 Some((col, tok)) => RmrkAccountIdOrCollectionNftTuple::CollectionAndNftTuple(col.0, tok.0),
177 Some(owner) => match <Runtime as pallet_common::Config>::CrossTokenAddressMapping::address_to_token(&owner) {177 None => RmrkAccountIdOrCollectionNftTuple::AccountId(owner.as_sub().clone())
178 Some((col, tok)) => RmrkAccountIdOrCollectionNftTuple::CollectionAndNftTuple(col.0, tok.0),178 },
179 None => RmrkAccountIdOrCollectionNftTuple::AccountId(owner.as_sub().clone())179 None => return Ok(None)
180 },180 };
181 None => return Ok(None)181
182 };182 let allowance = pallet_nonfungible::Allowance::<Runtime>::get((collection_id, nft_id));
183183
184 let allowance = pallet_nonfungible::Allowance::<Runtime>::get((collection_id, nft_id));184 Ok(Some(RmrkInstanceInfo {
185185 owner: owner,
186 Ok(Some(RmrkInstanceInfo {186 royalty: RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::RoyaltyInfo)?.decode_or_default(),
187 owner: owner,187 metadata: RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::Metadata)?.decode_or_default(),
188 royalty: RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::RoyaltyInfo)?.decode_or_default(),188 equipped: RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::Equipped)?.decode_or_default(),
189 metadata: RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::Metadata)?.decode_or_default(),189 pending: allowance.is_some(),
190 equipped: RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::Equipped)?.decode_or_default(),190 }))
191 pending: allowance.is_some(),191 }
192 }))192
193 }193 fn account_tokens(account_id: AccountId, collection_id: RmrkCollectionId) -> Result<Vec<RmrkNftId>, DispatchError> {
194194 use pallet_proxy_rmrk_core::misc::CollectionType;
195 fn account_tokens(account_id: AccountId, collection_id: RmrkCollectionId) -> Result<Vec<RmrkNftId>, DispatchError> {195
196 use pallet_proxy_rmrk_core::misc::CollectionType;196 let cross_account_id = CrossAccountId::from_sub(account_id);
197197 let collection_id = CollectionId(collection_id);
198 let cross_account_id = CrossAccountId::from_sub(account_id);198 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Regular).is_err() { return Ok(Vec::new()); }
199 let collection_id = CollectionId(collection_id);199
200 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Regular).is_err() { return Ok(Vec::new()); }200 Ok(
201201 dispatch_unique_runtime!(collection_id.account_tokens(cross_account_id))?
202 Ok(202 .into_iter()
203 dispatch_unique_runtime!(collection_id.account_tokens(cross_account_id))?203 .map(|token| token.0)
204 .into_iter()204 .collect()
205 .map(|token| token.0)205 )
206 .collect()206 }
207 )207
208 }208 fn nft_children(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkNftChild>, DispatchError> {
209209 let collection_id = CollectionId(collection_id);
210 fn nft_children(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkNftChild>, DispatchError> {210 let nft_id = TokenId(nft_id);
211 let collection_id = CollectionId(collection_id);211 if !RmrkCore::nft_exists(collection_id, nft_id) { return Ok(Vec::new()); }
212 let nft_id = TokenId(nft_id);212
213 if !RmrkCore::nft_exists(collection_id, nft_id) { return Ok(Vec::new()); }213 Ok(
214214 pallet_nonfungible::TokenChildren::<Runtime>::iter_prefix((collection_id, nft_id))
215 Ok(215 .filter_map(|(child_id, is_child)|
216 pallet_nonfungible::TokenChildren::<Runtime>::iter_prefix((collection_id, nft_id))216 match is_child {
217 .filter_map(|(child_id, is_child)|217 true => Some(RmrkNftChild {
218 match is_child {218 collection_id: child_id.0.0,
219 true => Some(RmrkNftChild {219 nft_id: child_id.1.0,
220 collection_id: child_id.0.0,220 }),
221 nft_id: child_id.1.0,221 false => None,
222 }),222 }
223 false => None,223 ).collect()
224 }224 )
225 ).collect()225 }
226 )226
227 }227 fn collection_properties(collection_id: RmrkCollectionId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {
228228 use pallet_proxy_rmrk_core::misc::CollectionType;
229 fn collection_properties(collection_id: RmrkCollectionId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {229
230 use pallet_proxy_rmrk_core::misc::CollectionType;230 let collection_id = CollectionId(collection_id);
231231 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Regular).is_err() {
232 let collection_id = CollectionId(collection_id);232 return Ok(Vec::new());
233 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Regular).is_err() {233 }
234 return Ok(Vec::new());234
235 }235 let properties = RmrkCore::filter_user_properties(
236236 collection_id,
237 let properties = RmrkCore::filter_user_properties(237 /* token_id = */ None,
238 collection_id,238 filter_keys,
239 /* token_id = */ None,239 |key, value| RmrkPropertyInfo {
240 filter_keys,240 key,
241 |key, value| RmrkPropertyInfo {241 value
242 key,242 }
243 value243 )?;
244 }244
245 )?;245 Ok(properties)
246246 }
247 Ok(properties)247
248 }248 fn nft_properties(collection_id: RmrkCollectionId, nft_id: RmrkNftId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {
249249 use pallet_proxy_rmrk_core::misc::NftType;
250 fn nft_properties(collection_id: RmrkCollectionId, nft_id: RmrkNftId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {250
251 use pallet_proxy_rmrk_core::misc::NftType;251 let collection_id = CollectionId(collection_id);
252252 let token_id = TokenId(nft_id);
253 let collection_id = CollectionId(collection_id);253
254 let token_id = TokenId(nft_id);254 if RmrkCore::ensure_nft_type(collection_id, token_id, NftType::Regular).is_err() {
255255 return Ok(Vec::new());
256 if RmrkCore::ensure_nft_type(collection_id, token_id, NftType::Regular).is_err() {256 }
257 return Ok(Vec::new());257
258 }258 let properties = RmrkCore::filter_user_properties(
259259 collection_id,
260 let properties = RmrkCore::filter_user_properties(260 Some(token_id),
261 collection_id,261 filter_keys,
262 Some(token_id),262 |key, value| RmrkPropertyInfo {
263 filter_keys,263 key,
264 |key, value| RmrkPropertyInfo {264 value
265 key,265 }
266 value266 )?;
267 }267
268 )?;268 Ok(properties)
269269 }
270 Ok(properties)270
271 }271 fn nft_resources(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkResourceInfo>, DispatchError> {
272272 use frame_support::BoundedVec;
273 fn nft_resources(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkResourceInfo>, DispatchError> {273 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, NftType, RmrkDecode}};
274 use frame_support::BoundedVec;274
275 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, NftType, RmrkDecode}};275 let collection_id = CollectionId(collection_id);
276276 if !RmrkCore::collection_exists(collection_id) { return Ok(Vec::new()); } // todo make sure the collection type doesn't matter
277 let collection_id = CollectionId(collection_id);277
278 if !RmrkCore::collection_exists(collection_id) { return Ok(Vec::new()); } // todo make sure the collection type doesn't matter278 let nft_id = TokenId(nft_id);
279279 if RmrkCore::ensure_nft_type(collection_id, nft_id, NftType::Resource).is_err() { return Ok(Vec::new()); }
280 let nft_id = TokenId(nft_id);280
281 if RmrkCore::ensure_nft_type(collection_id, nft_id, NftType::Resource).is_err() { return Ok(Vec::new()); }281 let resource_collection_id: CollectionId = RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::ResourceCollection)
282282 .unwrap()
283 let resource_collection_id: CollectionId = RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::ResourceCollection)283 .decode_or_default();
284 .unwrap()284 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Resource).is_err() { return Ok(Vec::new()); }
285 .decode_or_default();285
286 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Resource).is_err() { return Ok(Vec::new()); }286 let resources = pallet_nonfungible::TokenProperties::<Runtime>::iter_prefix((resource_collection_id,))
287287 .filter_map(|(resource_id, properties)| Some(RmrkResourceInfo {
288 let resources = pallet_nonfungible::TokenProperties::<Runtime>::iter_prefix((resource_collection_id,))288 id: BoundedVec::default(), // todo ResourceId property
289 .filter_map(|(resource_id, properties)| Some(RmrkResourceInfo {289 pending: RmrkCore::get_nft_property(resource_collection_id, resource_id, RmrkProperty::PendingResourceAccept).unwrap().decode_or_default(),
290 id: BoundedVec::default(), // todo ResourceId property290 pending_removal: RmrkCore::get_nft_property(resource_collection_id, resource_id, RmrkProperty::PendingResourceRemoval).unwrap().decode_or_default(),
291 pending: RmrkCore::get_nft_property(resource_collection_id, resource_id, RmrkProperty::PendingResourceAccept).unwrap().decode_or_default(),291 resource: RmrkCore::get_nft_property(resource_collection_id, resource_id, RmrkProperty::ResourceType).unwrap().decode_or_default(),/* {
292 pending_removal: RmrkCore::get_nft_property(resource_collection_id, resource_id, RmrkProperty::PendingResourceRemoval).unwrap().decode_or_default(),292 RmrkResourceTypes::Basic(resource) => RmrkResourceTypes::Basic(),/*(RmrkBasicResource {
293 resource: RmrkCore::get_nft_property(resource_collection_id, resource_id, RmrkProperty::ResourceType).unwrap().decode_or_default(),/* {293 src: RmrkCore::get_nft_property_inner(properties, RmrkProperty::Src).unwrap().decode_or_default(),
294 RmrkResourceTypes::Basic(resource) => RmrkResourceTypes::Basic(),/*(RmrkBasicResource {294 metadata: RmrkCore::get_nft_property_inner(properties, RmrkProperty::Metadata).unwrap().decode_or_default(),
295 src: RmrkCore::get_nft_property_inner(properties, RmrkProperty::Src).unwrap().decode_or_default(),295 license: RmrkCore::get_nft_property_inner(properties, RmrkProperty::License).unwrap().decode_or_default(),
296 metadata: RmrkCore::get_nft_property_inner(properties, RmrkProperty::Metadata).unwrap().decode_or_default(),296 thumb: RmrkCore::get_nft_property_inner(properties, RmrkProperty::Thumb).unwrap().decode_or_default(),
297 license: RmrkCore::get_nft_property_inner(properties, RmrkProperty::License).unwrap().decode_or_default(),297 },*///BasicResource<BoundedString>)
298 thumb: RmrkCore::get_nft_property_inner(properties, RmrkProperty::Thumb).unwrap().decode_or_default(),298 _ => todo!(), //RmrkResourceTypes::Composable(ComposableResource<BoundedString, BoundedParts>),
299 },*///BasicResource<BoundedString>)299 //RmrkResourceTypes::Slot(SlotResource<BoundedString>),
300 _ => todo!(), //RmrkResourceTypes::Composable(ComposableResource<BoundedString, BoundedParts>),300 },*/
301 //RmrkResourceTypes::Slot(SlotResource<BoundedString>),301 }))
302 },*/302 .collect();
303 }))303
304 .collect();304 Ok(resources)
305305 }
306 Ok(resources)306
307 }307 fn nft_resource_priorities(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkResourceId>, DispatchError> {
308308 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, NftType, RmrkDecode}};
309 fn nft_resource_priorities(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkResourceId>, DispatchError> {309
310 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, NftType, RmrkDecode}};310 let collection_id = CollectionId(collection_id);
311311 if !RmrkCore::collection_exists(collection_id) { return Ok(Vec::new()); } // todo ensure the collection type doesn't matter
312 let collection_id = CollectionId(collection_id);312
313 if !RmrkCore::collection_exists(collection_id) { return Ok(Vec::new()); } // todo ensure the collection type doesn't matter313 let nft_id = TokenId(nft_id);
314314 if RmrkCore::ensure_nft_type(collection_id, nft_id, NftType::Resource).is_err() { return Ok(Vec::new()); }
315 let nft_id = TokenId(nft_id);315
316 if RmrkCore::ensure_nft_type(collection_id, nft_id, NftType::Resource).is_err() { return Ok(Vec::new()); }316 /*let resource_collection_id: CollectionId = RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::ResourceCollection)
317317 .unwrap()
318 /*let resource_collection_id: CollectionId = RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::ResourceCollection)318 .decode_or_default();
319 .unwrap()319 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Resource).is_err() { return Ok(Vec::new()); }
320 .decode_or_default();320
321 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Resource).is_err() { return Ok(Vec::new()); }321 let resources = pallet_nonfungible::TokenProperties::<Runtime>::iter_prefix((resource_collection_id,))
322322 .filter_map(|(resource_id, properties)| Some((
323 let resources = pallet_nonfungible::TokenProperties::<Runtime>::iter_prefix((resource_collection_id,))323 resource_id, // ResourceId property
324 .filter_map(|(resource_id, properties)| Some((324 RmrkCore::get_nft_property(resource_collection_id, resource_id, RmrkProperty::Priority).unwrap().decode_or_default(),
325 resource_id, // ResourceId property325 )))
326 RmrkCore::get_nft_property(resource_collection_id, resource_id, RmrkProperty::Priority).unwrap().decode_or_default(),326 .collect()
327 )))327 .sort_by_key(|(_, index)| *index)
328 .collect()328 .into_iter().map(|(resource_id, _)| resource_id)*/
329 .sort_by_key(|(_, index)| *index)329 let priorities = RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::ResourcePriorities)?.decode_or_default();
330 .into_iter().map(|(resource_id, _)| resource_id)*/330
331 let priorities = RmrkCore::get_nft_property(collection_id, nft_id, RmrkProperty::ResourcePriorities)?.decode_or_default();331 Ok(priorities)
332332 }
333 Ok(priorities)333
334 }334 fn base(base_id: RmrkBaseId) -> Result<Option<RmrkBaseInfo<AccountId>>, DispatchError> {
335335 use pallet_proxy_rmrk_core::{
336 fn base(base_id: RmrkBaseId) -> Result<Option<RmrkBaseInfo<AccountId>>, DispatchError> {336 RmrkProperty, misc::{CollectionType, RmrkDecode, RmrkRebind},
337 use pallet_proxy_rmrk_core::{337 };
338 RmrkProperty, misc::{CollectionType, RmrkDecode, RmrkRebind},338
339 };339 let collection_id = CollectionId(base_id);
340340 let collection = match RmrkCore::get_typed_nft_collection(collection_id, CollectionType::Base) {
341 let collection_id = CollectionId(base_id);341 Ok(c) => c,
342 let collection = match RmrkCore::get_typed_nft_collection(collection_id, CollectionType::Base) {342 Err(_) => return Ok(None),
343 Ok(c) => c,343 };
344 Err(_) => return Ok(None),344
345 };345 Ok(Some(RmrkBaseInfo {
346346 issuer: collection.owner.clone(),
347 Ok(Some(RmrkBaseInfo {347 base_type: RmrkCore::get_collection_property(collection_id, RmrkProperty::BaseType)?.decode_or_default(),
348 issuer: collection.owner.clone(),348 symbol: collection.token_prefix.rebind(),
349 base_type: RmrkCore::get_collection_property(collection_id, RmrkProperty::BaseType)?.decode_or_default(),349 }))
350 symbol: collection.token_prefix.rebind(),350 }
351 }))351
352 }352 fn base_parts(base_id: RmrkBaseId) -> Result<Vec<RmrkPartType>, DispatchError> {
353353 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, NftType, RmrkDecode}};
354 fn base_parts(base_id: RmrkBaseId) -> Result<Vec<RmrkPartType>, DispatchError> {354
355 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, NftType, RmrkDecode}};355 let collection_id = CollectionId(base_id);
356356 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Base).is_err() { return Ok(Vec::new()); }
357 let collection_id = CollectionId(base_id);357
358 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Base).is_err() { return Ok(Vec::new()); }358 let parts = dispatch_unique_runtime!(collection_id.collection_tokens())?
359359 .into_iter()
360 let parts = dispatch_unique_runtime!(collection_id.collection_tokens())?360 .filter_map(|token_id| {
361 .into_iter()361 let nft_type = RmrkCore::get_nft_type(collection_id, token_id).ok()?;
362 .filter_map(|token_id| {362
363 let nft_type = RmrkCore::get_nft_type(collection_id, token_id).ok()?;363 match nft_type {
364364 NftType::FixedPart => Some(RmrkPartType::FixedPart(RmrkFixedPart {
365 match nft_type {365 id: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ExternalPartId).ok()?.decode_or_default(),
366 NftType::FixedPart => Some(RmrkPartType::FixedPart(RmrkFixedPart {366 src: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::Src).ok()?.decode_or_default(),
367 id: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ExternalPartId).ok()?.decode_or_default(),367 z: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ZIndex).ok()?.decode_or_default(),
368 src: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::Src).ok()?.decode_or_default(),368 })),
369 z: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ZIndex).ok()?.decode_or_default(),369 NftType::SlotPart => Some(RmrkPartType::SlotPart(RmrkSlotPart {
370 })),370 id: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ExternalPartId).ok()?.decode_or_default(),
371 NftType::SlotPart => Some(RmrkPartType::SlotPart(RmrkSlotPart {371 src: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::Src).ok()?.decode_or_default(),
372 id: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ExternalPartId).ok()?.decode_or_default(),372 z: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ZIndex).ok()?.decode_or_default(),
373 src: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::Src).ok()?.decode_or_default(),373 equippable: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::EquippableList).ok()?.decode_or_default(),
374 z: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ZIndex).ok()?.decode_or_default(),374 })),
375 equippable: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::EquippableList).ok()?.decode_or_default(),375 _ => None
376 })),376 }
377 _ => None377 })
378 }378 .collect();
379 })379
380 .collect();380 Ok(parts)
381381 }
382 Ok(parts)382
383 }383 fn theme_names(base_id: RmrkBaseId) -> Result<Vec<RmrkThemeName>, DispatchError> {
384384 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, RmrkDecode}};
385 fn theme_names(base_id: RmrkBaseId) -> Result<Vec<RmrkThemeName>, DispatchError> {385
386 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, RmrkDecode}};386 let collection_id = CollectionId(base_id);
387387 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Base).is_err() {
388 let collection_id = CollectionId(base_id);388 return Ok(Vec::new());
389 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Base).is_err() {389 }
390 return Ok(Vec::new());390
391 }391 let theme_names = dispatch_unique_runtime!(collection_id.collection_tokens())?
392392 .iter()
393 let theme_names = dispatch_unique_runtime!(collection_id.collection_tokens())?393 .filter_map(|token_id| {
394 .iter()394 let nft_type = RmrkCore::get_nft_type(collection_id, *token_id).unwrap();
395 .filter_map(|token_id| {395
396 let nft_type = RmrkCore::get_nft_type(collection_id, *token_id).unwrap();396 match nft_type {
397397 Theme => Some(
398 match nft_type {398 RmrkCore::get_nft_property(collection_id, *token_id, RmrkProperty::ThemeName).unwrap().decode_or_default()
399 Theme => Some(399 ),
400 RmrkCore::get_nft_property(collection_id, *token_id, RmrkProperty::ThemeName).unwrap().decode_or_default()400 _ => None
401 ),401 }
402 _ => None402 })
403 }403 .collect();
404 })404
405 .collect();405 Ok(theme_names)
406406 }
407 Ok(theme_names)407
408 }408 fn theme(base_id: RmrkBaseId, theme_name: RmrkThemeName, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Option<RmrkTheme>, DispatchError> {
409409 use pallet_proxy_rmrk_core::{
410 fn theme(base_id: RmrkBaseId, theme_name: RmrkThemeName, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Option<RmrkTheme>, DispatchError> {410 RmrkProperty,
411 use pallet_proxy_rmrk_core::{411 misc::{CollectionType, NftType, RmrkDecode}
412 RmrkProperty,412 };
413 misc::{CollectionType, NftType, RmrkDecode}413
414 };414 let collection_id = CollectionId(base_id);
415415 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Base).is_err() {
416 let collection_id = CollectionId(base_id);416 return Ok(None);
417 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Base).is_err() {417 }
418 return Ok(None);418
419 }419 let theme_info = dispatch_unique_runtime!(collection_id.collection_tokens())?
420420 .into_iter()
421 let theme_info = dispatch_unique_runtime!(collection_id.collection_tokens())?421 .find_map(|token_id| {
422 .into_iter()422 RmrkCore::ensure_nft_type(collection_id, token_id, NftType::Theme).ok()?;
423 .find_map(|token_id| {423
424 RmrkCore::ensure_nft_type(collection_id, token_id, NftType::Theme).ok()?;424 let name: RmrkString = RmrkCore::get_nft_property(
425425 collection_id, token_id, RmrkProperty::ThemeName
426 let name: RmrkString = RmrkCore::get_nft_property(426 ).ok()?.decode_or_default();
427 collection_id, token_id, RmrkProperty::ThemeName427
428 ).ok()?.decode_or_default();428 if name == theme_name {
429429 Some((name, token_id))
430 if name == theme_name {430 } else {
431 Some((name, token_id))431 None
432 } else {432 }
433 None433 });
434 }434
435 });435 let (name, theme_id) = match theme_info {
436436 Some((name, theme_id)) => (name, theme_id),
437 let (name, theme_id) = match theme_info {437 None => return Ok(None)
438 Some((name, theme_id)) => (name, theme_id),438 };
439 None => return Ok(None)439
440 };440 let properties = RmrkCore::filter_user_properties(
441441 collection_id,
442 let properties = RmrkCore::filter_user_properties(442 Some(theme_id),
443 collection_id,443 filter_keys,
444 Some(theme_id),444 |key, value| RmrkThemeProperty {
445 filter_keys,445 key,
446 |key, value| RmrkThemeProperty {446 value
447 key,447 }
448 value448 )?;
449 }449
450 )?;450 let inherit = RmrkCore::get_nft_property(
451451 collection_id,
452 let inherit = RmrkCore::get_nft_property(452 theme_id,
453 collection_id,453 RmrkProperty::ThemeInherit
454 theme_id,454 )?.decode_or_default();
455 RmrkProperty::ThemeInherit455
456 )?.decode_or_default();456 let theme = RmrkTheme {
457457 name,
458 let theme = RmrkTheme {458 properties,
459 name,459 inherit,
460 properties,460 };
461 inherit,461
462 };462 Ok(Some(theme))
463463 }
464 Ok(Some(theme))464 }
465 }
466 }*/
467465
468 impl sp_api::Core<Block> for Runtime {466 impl sp_api::Core<Block> for Runtime {
469 fn version() -> RuntimeVersion {467 fn version() -> RuntimeVersion {
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
914 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;914 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;
915}915}
916916
917/*917impl pallet_proxy_rmrk_core::Config for Runtime {
918TODO free RMRK!918 type Event = Event;
919impl pallet_proxy_rmrk_core::Config for Runtime {919}
920 type Event = Event;920
921}921impl pallet_proxy_rmrk_equip::Config for Runtime {
922922 type Event = Event;
923impl pallet_proxy_rmrk_equip::Config for Runtime {923}
924 type Event = Event;
925}*/
926924
927impl pallet_unique::Config for Runtime {925impl pallet_unique::Config for Runtime {
928 type Event = Event;926 type Event = Event;
1164 Refungible: pallet_refungible::{Pallet, Storage} = 68,1162 Refungible: pallet_refungible::{Pallet, Storage} = 68,
1165 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1163 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
1166 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1164 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,
1167 /* TODO free RMRK!1165 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,
1168 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,1166 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,
1169 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,
1170 */
11711167
1172 // Frontier1168 // Frontier
1173 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1169 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,
modifiedruntime/quartz/src/lib.rsdiffbeforeafterboth
912impl pallet_nonfungible::Config for Runtime {912impl pallet_nonfungible::Config for Runtime {
913 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;913 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;
914}914}
915/* TODO free RMRK!915
916impl pallet_proxy_rmrk_core::Config for Runtime {916impl pallet_proxy_rmrk_core::Config for Runtime {
917 type Event = Event;917 type Event = Event;
918}918}
919919
920impl pallet_proxy_rmrk_equip::Config for Runtime {920impl pallet_proxy_rmrk_equip::Config for Runtime {
921 type Event = Event;921 type Event = Event;
922}*/922}
923923
924impl pallet_unique::Config for Runtime {924impl pallet_unique::Config for Runtime {
925 type Event = Event;925 type Event = Event;
1160 Refungible: pallet_refungible::{Pallet, Storage} = 68,1160 Refungible: pallet_refungible::{Pallet, Storage} = 68,
1161 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1161 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
1162 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1162 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,
1163 /* TODO free RMRK!1163 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,
1164 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,1164 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,
1165 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,*/
11661165
1167 // Frontier1166 // Frontier
1168 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1167 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,
modifiedruntime/unique/src/lib.rsdiffbeforeafterboth
911impl pallet_nonfungible::Config for Runtime {911impl pallet_nonfungible::Config for Runtime {
912 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;912 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;
913}913}
914/* TODO free RMRK!914
915impl pallet_proxy_rmrk_core::Config for Runtime {915impl pallet_proxy_rmrk_core::Config for Runtime {
916 type Event = Event;916 type Event = Event;
917}917}
918918
919impl pallet_proxy_rmrk_equip::Config for Runtime {919impl pallet_proxy_rmrk_equip::Config for Runtime {
920 type Event = Event;920 type Event = Event;
921}*/921}
922922
923impl pallet_unique::Config for Runtime {923impl pallet_unique::Config for Runtime {
924 type Event = Event;924 type Event = Event;
1159 Refungible: pallet_refungible::{Pallet, Storage} = 68,1159 Refungible: pallet_refungible::{Pallet, Storage} = 68,
1160 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1160 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
1161 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1161 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,
1162 /* TODO free RMRK!1162 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,
1163 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,1163 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,
1164 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,*/
11651164
1166 // Frontier1165 // Frontier
1167 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1166 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,
modifiedtests/src/interfaces/definitions.tsdiffbeforeafterboth
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17export {default as unique} from './unique/definitions';17export {default as unique} from './unique/definitions';
18// TODO free RMRK! export {default as rmrk} from './rmrk/definitions';18export {default as rmrk} from './rmrk/definitions';
19export {default as default} from './default/definitions';19export {default as default} from './default/definitions';
modifiedtests/src/substrate/substrate-api.tsdiffbeforeafterboth
42 },42 },
43 rpc: {43 rpc: {
44 unique: defs.unique.rpc,44 unique: defs.unique.rpc,
45 // TODO free RMRK! rmrk: defs.rmrk.rpc,45 rmrk: defs.rmrk.rpc,
46 eth: {46 eth: {
47 feeHistory: {47 feeHistory: {
48 description: 'Dummy',48 description: 'Dummy',