difftreelog
fix restore foreign flag, minor fixes
in: master
11 files changed
pallets/common/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/common/src/benchmarking.rs
+++ b/pallets/common/src/benchmarking.rs
@@ -121,7 +121,7 @@
owner,
CollectionMode::NFT,
|owner: T::CrossAccountId, data| {
- <Pallet<T>>::init_collection(owner.clone(), Some(owner), data)
+ <Pallet<T>>::init_collection(owner.clone(), Some(owner), false, data)
},
|h| h,
)
pallets/common/src/dispatch.rsdiffbeforeafterboth--- a/pallets/common/src/dispatch.rs
+++ b/pallets/common/src/dispatch.rs
@@ -78,6 +78,21 @@
sender: T::CrossAccountId,
payer: Option<T::CrossAccountId>,
data: CreateCollectionData<T::CrossAccountId>,
+ ) -> Result<CollectionId, DispatchError> {
+ Self::create_internal(sender, payer, false, data)
+ }
+
+ /// Create a collection. The collection will be created according to the value of [`data.mode`](CreateCollectionData::mode).
+ ///
+ /// * `sender` - The user who will become the owner of the collection.
+ /// * `payer` - If set, the user who pays the collection creation deposit.
+ /// * `data` - Description of the created collection.
+ /// * `is_special_collection` -- Whether this collection is a system one, i.e. can have special flags set.
+ fn create_internal(
+ sender: T::CrossAccountId,
+ payer: Option<T::CrossAccountId>,
+ is_special_collection: bool,
+ data: CreateCollectionData<T::CrossAccountId>,
) -> Result<CollectionId, DispatchError>;
/// Delete the collection.
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -1088,6 +1088,7 @@
read_only: flags.external,
flags: RpcCollectionFlags {
+ foreign: flags.foreign,
erc721metadata: flags.erc721metadata,
},
})
@@ -1129,12 +1130,16 @@
/// * `owner` - The owner of the collection.
/// * `payer` - If set, the user that will pay a deposit for the collection creation.
/// * `data` - Description of the created collection.
+ /// * `is_special_collection` -- Whether this collection is a special one, i.e. can have special flags set.
pub fn init_collection(
owner: T::CrossAccountId,
payer: Option<T::CrossAccountId>,
+ is_special_collection: bool,
data: CreateCollectionData<T::CrossAccountId>,
) -> Result<CollectionId, DispatchError> {
- ensure!(data.flags.is_allowed_for_user(), <Error<T>>::NoPermission);
+ if !is_special_collection {
+ ensure!(data.flags.is_allowed_for_user(), <Error<T>>::NoPermission);
+ }
// Take a (non-refundable) deposit of collection creation
if let Some(payer) = payer {
pallets/foreign-assets/src/lib.rsdiffbeforeafterboth--- a/pallets/foreign-assets/src/lib.rs
+++ b/pallets/foreign-assets/src/lib.rs
@@ -153,9 +153,11 @@
.expect("description length < max description length; qed");
let payer = None;
- let collection_id = T::CollectionDispatch::create(
+ let is_special_collection = true;
+ let collection_id = T::CollectionDispatch::create_internal(
foreign_collection_owner,
payer,
+ is_special_collection,
CreateCollectionData {
name,
description,
pallets/fungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/fungible/src/benchmarking.rs
+++ b/pallets/fungible/src/benchmarking.rs
@@ -31,7 +31,7 @@
owner,
CollectionMode::Fungible(0),
|owner: T::CrossAccountId, data| {
- <PalletCommon<T>>::init_collection(owner.clone(), Some(owner), data)
+ <PalletCommon<T>>::init_collection(owner.clone(), Some(owner), false, data)
},
FungibleHandle::cast,
)
pallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -58,7 +58,7 @@
owner,
CollectionMode::NFT,
|owner: T::CrossAccountId, data| {
- <PalletCommon<T>>::init_collection(owner.clone(), Some(owner), data)
+ <PalletCommon<T>>::init_collection(owner.clone(), Some(owner), false, data)
},
NonfungibleHandle::cast,
)
pallets/refungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/refungible/src/benchmarking.rs
+++ b/pallets/refungible/src/benchmarking.rs
@@ -20,6 +20,7 @@
use pallet_common::{
bench_init,
benchmarking::{create_collection_raw, property_key, property_value},
+ Pallet as PalletCommon,
};
use sp_std::prelude::*;
use up_data_structs::{
@@ -61,7 +62,9 @@
create_collection_raw(
owner,
CollectionMode::ReFungible,
- |owner: T::CrossAccountId, data| <Pallet<T>>::init_collection(owner.clone(), owner, data),
+ |owner: T::CrossAccountId, data| {
+ <PalletCommon<T>>::init_collection(owner.clone(), Some(owner), false, data)
+ },
RefungibleHandle::cast,
)
}
pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -103,7 +103,7 @@
use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, TransactionOutcome};
use sp_std::{collections::btree_map::BTreeMap, vec, vec::Vec};
use up_data_structs::{
- budget::Budget, mapping::TokenAddressMapping, AccessMode, CollectionId, CreateCollectionData,
+ budget::Budget, mapping::TokenAddressMapping, AccessMode, CollectionId,
CreateRefungibleExMultipleOwners, PropertiesPermissionMap, Property, PropertyKey,
PropertyKeyPermission, PropertyScope, PropertyValue, TokenId, TokenOwnerError,
TokenProperties as TokenPropertiesT, MAX_REFUNGIBLE_PIECES,
@@ -296,19 +296,6 @@
// unchecked calls skips any permission checks
impl<T: Config> Pallet<T> {
- /// Create RFT collection
- ///
- /// `init_collection` will take non-refundable deposit for collection creation.
- ///
- /// - `data`: Contains settings for collection limits and permissions.
- pub fn init_collection(
- owner: T::CrossAccountId,
- payer: T::CrossAccountId,
- data: CreateCollectionData<T::CrossAccountId>,
- ) -> Result<CollectionId, DispatchError> {
- <PalletCommon<T>>::init_collection(owner, Some(payer), data)
- }
-
/// Destroy RFT collection
///
/// `destroy_collection` will throw error if collection contains any tokens.
primitives/data-structs/src/lib.rsdiffbeforeafterboth--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -380,7 +380,7 @@
pub struct CollectionFlags {
/// Reserved flag
#[bondrewd(bits = "0..1")]
- pub reserved_0: bool,
+ pub foreign: bool,
/// Supports ERC721Metadata
#[bondrewd(bits = "1..2")]
pub erc721metadata: bool,
@@ -395,7 +395,7 @@
impl CollectionFlags {
pub fn is_allowed_for_user(self) -> bool {
- !self.reserved_0 && !self.external && self.reserved == 0
+ !self.foreign && !self.external && self.reserved == 0
}
}
@@ -461,6 +461,8 @@
#[derive(Debug, Encode, Decode, Clone, PartialEq, TypeInfo, Serialize, Deserialize)]
pub struct RpcCollectionFlags {
+ /// Is collection is foreign.
+ pub foreign: bool,
/// Collection supports ERC721Metadata.
pub erc721metadata: bool,
}
@@ -503,7 +505,7 @@
pub read_only: bool,
/// Extra collection flags
- #[version(2.., upper(RpcCollectionFlags {erc721metadata: false}))]
+ #[version(2.., upper(RpcCollectionFlags {foreign: false, erc721metadata: false}))]
pub flags: RpcCollectionFlags,
}
@@ -540,6 +542,7 @@
read_only: true,
flags: RpcCollectionFlags {
+ foreign: false,
erc721metadata: false,
},
}
runtime/common/config/pallets/foreign_asset.rsdiffbeforeafterboth--- a/runtime/common/config/pallets/foreign_asset.rs
+++ b/runtime/common/config/pallets/foreign_asset.rs
@@ -1,4 +1,6 @@
use frame_support::{parameter_types, PalletId};
+#[cfg(not(feature = "governance"))]
+use frame_system::EnsureRoot;
use pallet_evm::account::CrossAccountId;
use sp_core::H160;
use staging_xcm::prelude::*;
@@ -6,10 +8,6 @@
#[cfg(feature = "governance")]
use crate::runtime_common::config::governance;
-
-#[cfg(not(feature = "governance"))]
-use frame_system::EnsureRoot;
-
use crate::{
runtime_common::config::{
ethereum::CrossAccountId as ConfigCrossAccountId,
runtime/common/dispatch.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use frame_support::{dispatch::DispatchResult, ensure, fail};18use pallet_balances_adapter::NativeFungibleHandle;19pub use pallet_common::dispatch::CollectionDispatch;20use pallet_common::{21 erc::CommonEvmHandler, eth::map_eth_to_id, CollectionById, CollectionHandle,22 CommonCollectionOperations, Pallet as PalletCommon,23};24use pallet_evm::{PrecompileHandle, PrecompileResult};25use pallet_fungible::{FungibleHandle, Pallet as PalletFungible};26use pallet_nonfungible::{NonfungibleHandle, Pallet as PalletNonfungible};27use pallet_refungible::{28 erc_token::RefungibleTokenHandle, Pallet as PalletRefungible, RefungibleHandle,29};30use sp_core::H160;31use sp_runtime::DispatchError;32use sp_std::{borrow::ToOwned, vec::Vec};33use up_data_structs::{34 mapping::TokenAddressMapping, CollectionId, CollectionMode, CreateCollectionData,35 MAX_DECIMAL_POINTS,36};3738pub enum CollectionDispatchT<T>39where40 T: pallet_fungible::Config41 + pallet_nonfungible::Config42 + pallet_refungible::Config43 + pallet_balances_adapter::Config,44{45 Fungible(FungibleHandle<T>),46 Nonfungible(NonfungibleHandle<T>),47 Refungible(RefungibleHandle<T>),48 NativeFungible(NativeFungibleHandle<T>),49}5051impl<T> CollectionDispatch<T> for CollectionDispatchT<T>52where53 T: pallet_common::Config54 + pallet_unique::Config55 + pallet_fungible::Config56 + pallet_nonfungible::Config57 + pallet_refungible::Config58 + pallet_balances_adapter::Config,59{60 fn check_is_internal(&self) -> DispatchResult {61 match self {62 Self::Fungible(h) => h.check_is_internal(),63 Self::Nonfungible(h) => h.check_is_internal(),64 Self::Refungible(h) => h.check_is_internal(),65 Self::NativeFungible(h) => h.check_is_internal(),66 }67 }6869 fn create(70 sender: T::CrossAccountId,71 payer: Option<T::CrossAccountId>,72 data: CreateCollectionData<T::CrossAccountId>,73 ) -> Result<CollectionId, DispatchError> {74 match data.mode {75 CollectionMode::Fungible(decimal_points) => {76 // check params77 ensure!(78 decimal_points <= MAX_DECIMAL_POINTS,79 pallet_unique::Error::<T>::CollectionDecimalPointLimitExceeded80 );81 }8283 #[cfg(not(feature = "refungible"))]84 CollectionMode::ReFungible => return unsupported!(T),8586 _ => {}87 };8889 <PalletCommon<T>>::init_collection(sender, payer, data)90 }9192 fn destroy(sender: T::CrossAccountId, collection_id: CollectionId) -> DispatchResult {93 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {94 fail!(<pallet_common::Error<T>>::UnsupportedOperation);95 }9697 let collection = <CollectionHandle<T>>::try_get(collection_id)?;9899 match collection.mode {100 CollectionMode::ReFungible => {101 PalletRefungible::destroy_collection(RefungibleHandle::cast(collection), &sender)?102 }103 CollectionMode::Fungible(_) => {104 PalletFungible::destroy_collection(FungibleHandle::cast(collection), &sender)?105 }106 CollectionMode::NFT => {107 PalletNonfungible::destroy_collection(NonfungibleHandle::cast(collection), &sender)?108 }109 }110 Ok(())111 }112113 fn dispatch(collection_id: CollectionId) -> Result<Self, DispatchError> {114 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {115 return Ok(Self::NativeFungible(116 NativeFungibleHandle::new_with_gas_limit(u64::MAX),117 ));118 }119120 let handle = <CollectionHandle<T>>::try_get(collection_id)?;121 Ok(match handle.mode {122 CollectionMode::Fungible(_) => Self::Fungible(FungibleHandle::cast(handle)),123 CollectionMode::NFT => Self::Nonfungible(NonfungibleHandle::cast(handle)),124 CollectionMode::ReFungible => Self::Refungible(RefungibleHandle::cast(handle)),125 })126 }127128 fn as_dyn(&self) -> &dyn CommonCollectionOperations<T> {129 match self {130 Self::Fungible(h) => h,131 Self::Nonfungible(h) => h,132 Self::Refungible(h) => h,133 Self::NativeFungible(h) => h,134 }135 }136}137138impl<T> pallet_evm::OnMethodCall<T> for CollectionDispatchT<T>139where140 T: pallet_common::Config141 + pallet_unique::Config142 + pallet_fungible::Config143 + pallet_nonfungible::Config144 + pallet_refungible::Config145 + pallet_balances_adapter::Config,146 T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,147{148 fn is_reserved(target: &H160) -> bool {149 map_eth_to_id(target).is_some()150 }151 fn is_used(target: &H160) -> bool {152 map_eth_to_id(target)153 .map(<CollectionById<T>>::contains_key)154 .unwrap_or(false)155 }156 fn get_code(target: &H160) -> Option<Vec<u8>> {157 if let Some(collection_id) = map_eth_to_id(target) {158 let collection = <CollectionById<T>>::get(collection_id)?;159 Some(160 match collection.mode {161 CollectionMode::NFT => <NonfungibleHandle<T>>::CODE,162 CollectionMode::Fungible(_) => <FungibleHandle<T>>::CODE,163 CollectionMode::ReFungible => <RefungibleHandle<T>>::CODE,164 }165 .to_owned(),166 )167 } else if let Some((collection_id, _token_id)) =168 <T as pallet_common::Config>::EvmTokenAddressMapping::address_to_token(target)169 {170 let collection = <CollectionById<T>>::get(collection_id)?;171 if collection.mode != CollectionMode::ReFungible {172 return None;173 }174 // TODO: check token existence175 Some(<RefungibleTokenHandle<T>>::CODE.to_owned())176 } else {177 None178 }179 }180 fn call(handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {181 if let Some(collection_id) = map_eth_to_id(&handle.code_address()) {182 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {183 <NativeFungibleHandle<T>>::new_with_gas_limit(handle.remaining_gas()).call(handle)184 } else {185 let collection = <CollectionHandle<T>>::new_with_gas_limit(186 collection_id,187 handle.remaining_gas(),188 )?;189190 match collection.mode {191 CollectionMode::Fungible(_) => FungibleHandle::cast(collection).call(handle),192 CollectionMode::NFT => NonfungibleHandle::cast(collection).call(handle),193 CollectionMode::ReFungible => RefungibleHandle::cast(collection).call(handle),194 }195 }196 } else if let Some((collection_id, token_id)) =197 <T as pallet_common::Config>::EvmTokenAddressMapping::address_to_token(198 &handle.code_address(),199 ) {200 let collection =201 <CollectionHandle<T>>::new_with_gas_limit(collection_id, handle.remaining_gas())?;202 if collection.mode != CollectionMode::ReFungible {203 return None;204 }205206 let h = RefungibleHandle::cast(collection);207 // TODO: check token existence208 RefungibleTokenHandle(h, token_id).call(handle)209 } else {210 None211 }212 }213}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use frame_support::{dispatch::DispatchResult, ensure, fail};18use pallet_balances_adapter::NativeFungibleHandle;19pub use pallet_common::dispatch::CollectionDispatch;20use pallet_common::{21 erc::CommonEvmHandler, eth::map_eth_to_id, CollectionById, CollectionHandle,22 CommonCollectionOperations, Pallet as PalletCommon,23};24use pallet_evm::{PrecompileHandle, PrecompileResult};25use pallet_fungible::{FungibleHandle, Pallet as PalletFungible};26use pallet_nonfungible::{NonfungibleHandle, Pallet as PalletNonfungible};27use pallet_refungible::{28 erc_token::RefungibleTokenHandle, Pallet as PalletRefungible, RefungibleHandle,29};30use sp_core::H160;31use sp_runtime::DispatchError;32use sp_std::{borrow::ToOwned, vec::Vec};33use up_data_structs::{34 mapping::TokenAddressMapping, CollectionId, CollectionMode, CreateCollectionData,35 MAX_DECIMAL_POINTS,36};3738pub enum CollectionDispatchT<T>39where40 T: pallet_fungible::Config41 + pallet_nonfungible::Config42 + pallet_refungible::Config43 + pallet_balances_adapter::Config,44{45 Fungible(FungibleHandle<T>),46 Nonfungible(NonfungibleHandle<T>),47 Refungible(RefungibleHandle<T>),48 NativeFungible(NativeFungibleHandle<T>),49}5051impl<T> CollectionDispatch<T> for CollectionDispatchT<T>52where53 T: pallet_common::Config54 + pallet_unique::Config55 + pallet_fungible::Config56 + pallet_nonfungible::Config57 + pallet_refungible::Config58 + pallet_balances_adapter::Config,59{60 fn check_is_internal(&self) -> DispatchResult {61 match self {62 Self::Fungible(h) => h.check_is_internal(),63 Self::Nonfungible(h) => h.check_is_internal(),64 Self::Refungible(h) => h.check_is_internal(),65 Self::NativeFungible(h) => h.check_is_internal(),66 }67 }6869 fn create_internal(70 sender: T::CrossAccountId,71 payer: Option<T::CrossAccountId>,72 is_special_collection: bool,73 data: CreateCollectionData<T::CrossAccountId>,74 ) -> Result<CollectionId, DispatchError> {75 match data.mode {76 CollectionMode::Fungible(decimal_points) => {77 // check params78 ensure!(79 decimal_points <= MAX_DECIMAL_POINTS,80 pallet_unique::Error::<T>::CollectionDecimalPointLimitExceeded81 );82 }8384 #[cfg(not(feature = "refungible"))]85 CollectionMode::ReFungible => return unsupported!(T),8687 _ => {}88 };8990 <PalletCommon<T>>::init_collection(sender, payer, is_special_collection, data)91 }9293 fn destroy(sender: T::CrossAccountId, collection_id: CollectionId) -> DispatchResult {94 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {95 fail!(<pallet_common::Error<T>>::UnsupportedOperation);96 }9798 let collection = <CollectionHandle<T>>::try_get(collection_id)?;99100 match collection.mode {101 CollectionMode::ReFungible => {102 PalletRefungible::destroy_collection(RefungibleHandle::cast(collection), &sender)?103 }104 CollectionMode::Fungible(_) => {105 PalletFungible::destroy_collection(FungibleHandle::cast(collection), &sender)?106 }107 CollectionMode::NFT => {108 PalletNonfungible::destroy_collection(NonfungibleHandle::cast(collection), &sender)?109 }110 }111 Ok(())112 }113114 fn dispatch(collection_id: CollectionId) -> Result<Self, DispatchError> {115 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {116 return Ok(Self::NativeFungible(117 NativeFungibleHandle::new_with_gas_limit(u64::MAX),118 ));119 }120121 let handle = <CollectionHandle<T>>::try_get(collection_id)?;122 Ok(match handle.mode {123 CollectionMode::Fungible(_) => Self::Fungible(FungibleHandle::cast(handle)),124 CollectionMode::NFT => Self::Nonfungible(NonfungibleHandle::cast(handle)),125 CollectionMode::ReFungible => Self::Refungible(RefungibleHandle::cast(handle)),126 })127 }128129 fn as_dyn(&self) -> &dyn CommonCollectionOperations<T> {130 match self {131 Self::Fungible(h) => h,132 Self::Nonfungible(h) => h,133 Self::Refungible(h) => h,134 Self::NativeFungible(h) => h,135 }136 }137}138139impl<T> pallet_evm::OnMethodCall<T> for CollectionDispatchT<T>140where141 T: pallet_common::Config142 + pallet_unique::Config143 + pallet_fungible::Config144 + pallet_nonfungible::Config145 + pallet_refungible::Config146 + pallet_balances_adapter::Config,147 T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,148{149 fn is_reserved(target: &H160) -> bool {150 map_eth_to_id(target).is_some()151 }152 fn is_used(target: &H160) -> bool {153 map_eth_to_id(target)154 .map(<CollectionById<T>>::contains_key)155 .unwrap_or(false)156 }157 fn get_code(target: &H160) -> Option<Vec<u8>> {158 if let Some(collection_id) = map_eth_to_id(target) {159 let collection = <CollectionById<T>>::get(collection_id)?;160 Some(161 match collection.mode {162 CollectionMode::NFT => <NonfungibleHandle<T>>::CODE,163 CollectionMode::Fungible(_) => <FungibleHandle<T>>::CODE,164 CollectionMode::ReFungible => <RefungibleHandle<T>>::CODE,165 }166 .to_owned(),167 )168 } else if let Some((collection_id, _token_id)) =169 <T as pallet_common::Config>::EvmTokenAddressMapping::address_to_token(target)170 {171 let collection = <CollectionById<T>>::get(collection_id)?;172 if collection.mode != CollectionMode::ReFungible {173 return None;174 }175 // TODO: check token existence176 Some(<RefungibleTokenHandle<T>>::CODE.to_owned())177 } else {178 None179 }180 }181 fn call(handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {182 if let Some(collection_id) = map_eth_to_id(&handle.code_address()) {183 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {184 <NativeFungibleHandle<T>>::new_with_gas_limit(handle.remaining_gas()).call(handle)185 } else {186 let collection = <CollectionHandle<T>>::new_with_gas_limit(187 collection_id,188 handle.remaining_gas(),189 )?;190191 match collection.mode {192 CollectionMode::Fungible(_) => FungibleHandle::cast(collection).call(handle),193 CollectionMode::NFT => NonfungibleHandle::cast(collection).call(handle),194 CollectionMode::ReFungible => RefungibleHandle::cast(collection).call(handle),195 }196 }197 } else if let Some((collection_id, token_id)) =198 <T as pallet_common::Config>::EvmTokenAddressMapping::address_to_token(199 &handle.code_address(),200 ) {201 let collection =202 <CollectionHandle<T>>::new_with_gas_limit(collection_id, handle.remaining_gas())?;203 if collection.mode != CollectionMode::ReFungible {204 return None;205 }206207 let h = RefungibleHandle::cast(collection);208 // TODO: check token existence209 RefungibleTokenHandle(h, token_id).call(handle)210 } else {211 None212 }213 }214}