git.delta.rocks / unique-network / refs/commits / d4149b5fdc00

difftreelog

feat(pallet-refungible) implement property RPC

Yaroslav Bolyukin2022-08-08parent: #40aceba.patch.diff
in: master

2 files changed

modifiedpallets/refungible/src/common.rsdiffbeforeafterboth
3333
34use crate::{34use crate::{
35 AccountBalance, Allowance, Balance, Config, Error, Owned, Pallet, RefungibleHandle,35 AccountBalance, Allowance, Balance, Config, Error, Owned, Pallet, RefungibleHandle,
36 SelfWeightOf, TokenData, weights::WeightInfo, TokensMinted, TotalSupply, CreateItemData,36 SelfWeightOf, weights::WeightInfo, TokensMinted, TotalSupply, CreateItemData,
37};37};
3838
39macro_rules! max_weight_of {39macro_rules! max_weight_of {
457 <Pallet<T>>::token_owners(self.id, token).unwrap_or_default()457 <Pallet<T>>::token_owners(self.id, token).unwrap_or_default()
458 }458 }
459459
460 fn token_property(&self, _token_id: TokenId, _key: &PropertyKey) -> Option<PropertyValue> {460 fn token_property(&self, token_id: TokenId, key: &PropertyKey) -> Option<PropertyValue> {
461 None461 <Pallet<T>>::token_properties((self.id, token_id))
462 .get(key)
463 .cloned()
462 }464 }
463465
464 fn token_properties(466 fn token_properties(&self, token_id: TokenId, keys: Option<Vec<PropertyKey>>) -> Vec<Property> {
465 &self,
466 _token_id: TokenId,
467 _keys: Option<Vec<PropertyKey>>,
468 ) -> Vec<Property> {
469 Vec::new()467 let properties = <Pallet<T>>::token_properties((self.id, token_id));
468
469 keys.map(|keys| {
470 keys.into_iter()
471 .filter_map(|key| {
472 properties.get(&key).map(|value| Property {
473 key,
474 value: value.clone(),
475 })
476 })
477 .collect()
478 })
479 .unwrap_or_else(|| {
480 properties
481 .into_iter()
482 .map(|(key, value)| Property { key, value })
483 .collect()
484 })
470 }485 }
471486
472 fn total_supply(&self) -> u32 {487 fn total_supply(&self) -> u32 {
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
27 convert::TryInto,27 convert::TryInto,
28};28};
29use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};29use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};
30use frame_support::{BoundedBTreeMap, BoundedVec};30use frame_support::BoundedBTreeMap;
31use pallet_common::{31use pallet_common::{
32 CollectionHandle, CollectionPropertyPermissions,32 CollectionHandle, CollectionPropertyPermissions,
33 erc::{33 erc::{