difftreelog
Add rpc method for total_pieces
in: master
8 files changed
client/rpc/src/lib.rsdiffbeforeafterboth191 at: Option<BlockHash>,192 at: Option<BlockHash>,192 ) -> Result<Option<CollectionLimits>>;193 ) -> Result<Option<CollectionLimits>>;194195 #[method(name = "unique_totalPieces")]196 fn total_pieces(197 &self,198 collection_id: CollectionId,199 token_id: TokenId,200 at: Option<BlockHash>,201 ) -> Result<u128>;193}202}194203195mod rmrk_unique_rpc {204mod rmrk_unique_rpc {463 pass_method!(collection_stats() -> CollectionStats, unique_api);472 pass_method!(collection_stats() -> CollectionStats, unique_api);464 pass_method!(next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Option<u64>, unique_api);473 pass_method!(next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Option<u64>, unique_api);465 pass_method!(effective_collection_limits(collection_id: CollectionId) -> Option<CollectionLimits>, unique_api);474 pass_method!(effective_collection_limits(collection_id: CollectionId) -> Option<CollectionLimits>, unique_api);475 pass_method!(total_pieces(collection_id: CollectionId, token_id: TokenId) -> u128, unique_api);466}476}467477468#[allow(deprecated)]478#[allow(deprecated)]pallets/common/src/lib.rsdiffbeforeafterboth1382 fn account_balance(&self, account: T::CrossAccountId) -> u32;1382 fn account_balance(&self, account: T::CrossAccountId) -> u32;1383 /// Amount of specific token account have (Applicable to fungible/refungible)1383 /// Amount of specific token account have (Applicable to fungible/refungible)1384 fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128;1384 fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128;1385 /// Amount of token pieces1386 fn total_pieces(&self, token: TokenId) -> u128;1385 fn allowance(1387 fn allowance(1386 &self,1388 &self,1387 sender: T::CrossAccountId,1389 sender: T::CrossAccountId,pallets/fungible/src/common.rsdiffbeforeafterboth404 None404 None405 }405 }406407 fn total_pieces(&self, _token: TokenId) -> u128 {408 0409 }406}410}407411pallets/nonfungible/src/common.rsdiffbeforeafterboth473 None473 None474 }474 }475476 fn total_pieces(&self, _token: TokenId) -> u128 {477 1478 }475}479}476480pallets/refungible/src/common.rsdiffbeforeafterboth410 Some(self)410 Some(self)411 }411 }412413 fn total_pieces(&self, token: TokenId) -> u128 {414 <Pallet<T>>::total_pieces(self.id, token)415 }412}416}413417414impl<T: Config> RefungibleExtensions<T> for RefungibleHandle<T> {418impl<T: Config> RefungibleExtensions<T> for RefungibleHandle<T> {pallets/refungible/src/lib.rsdiffbeforeafterboth711 Ok(())711 Ok(())712 }712 }713714 fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> u128 {715 // Not "try_fold" because total count of pieces is limited by 'MAX_REFUNGIBLE_PIECES'.716 <Balance<T>>::iter_prefix((collection_id, token_id)).fold(0, |total, piece| total + piece.1)717 }713}718}714719primitives/rpc/src/lib.rsdiffbeforeafterboth80 fn collection_stats() -> Result<CollectionStats>;80 fn collection_stats() -> Result<CollectionStats>;81 fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>>;81 fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>>;82 fn effective_collection_limits(collection_id: CollectionId) -> Result<Option<CollectionLimits>>;82 fn effective_collection_limits(collection_id: CollectionId) -> Result<Option<CollectionLimits>>;83 fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> Result<u128>;83 }84 }84}85}8586runtime/common/src/runtime_apis.rsdiffbeforeafterboth143 Ok(<pallet_common::Pallet<Runtime>>::effective_collection_limits(collection))143 Ok(<pallet_common::Pallet<Runtime>>::effective_collection_limits(collection))144 }144 }145146 fn total_pieces(collection: CollectionId, token_id: TokenId) -> Result<u128, DispatchError> {147 dispatch_unique_runtime!(collection.total_pieces(token_id))148 }145 }149 }146150147 impl sp_api::Core<Block> for Runtime {151 impl sp_api::Core<Block> for Runtime {