difftreelog
fix PR comments
in: master
8 files changed
pallets/balances-adapter/src/common.rsdiffbeforeafterboth--- a/pallets/balances-adapter/src/common.rs
+++ b/pallets/balances-adapter/src/common.rs
@@ -7,6 +7,8 @@
use up_data_structs::TokenId;
pub struct CommonWeights<T: Config>(PhantomData<T>);
+
+// All implementations with `Weight::default` used in methods that return error `UnsupportedOperation`.
impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {
fn create_multiple_items(_amount: &[up_data_structs::CreateItemData]) -> Weight {
Weight::default()
pallets/balances-adapter/src/erc.rsdiffbeforeafterboth--- a/pallets/balances-adapter/src/erc.rs
+++ b/pallets/balances-adapter/src/erc.rs
@@ -1,9 +1,8 @@
use crate::{Config, NativeFungibleHandle, Pallet, SelfWeightOf};
-use evm_coder::{abi::AbiType, ToLog, generate_stubgen, solidity_interface, types::*};
-use frame_support::traits::{Currency, ExistenceRequirement};
+use evm_coder::{abi::AbiType, generate_stubgen, solidity_interface, types::*};
+use frame_support::traits::{Currency};
use pallet_balances::WeightInfo;
use pallet_common::{
- consume_store_reads,
erc::{CommonEvmHandler, CrossAccountId, PrecompileHandle, PrecompileResult},
eth::CrossAddress,
};
@@ -14,38 +13,24 @@
};
use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};
use sp_core::{U256, Get};
-use sp_std::vec::Vec;
frontier_contract! {
macro_rules! NativeFungibleHandle_result {...}
impl<T: Config> Contract for NativeFungibleHandle<T> {...}
}
-#[derive(ToLog)]
-pub enum ERC20Events {
- Transfer {
- #[indexed]
- from: Address,
- #[indexed]
- to: Address,
- value: U256,
- },
-}
-
-#[solidity_interface(name = ERC20, events(ERC20Events), enum(derive(PreDispatch)), enum_attr(weight), expect_selector = 0x942e8b22)]
+#[solidity_interface(name = ERC20, enum(derive(PreDispatch)), enum_attr(weight), expect_selector = 0x942e8b22)]
impl<T: Config> NativeFungibleHandle<T> {
fn allowance(&self, _owner: Address, _spender: Address) -> Result<U256> {
Ok(U256::zero())
}
- // #[weight(<SelfWeightOf<T>>::approve())]
fn approve(&mut self, _caller: Caller, _spender: Address, _amount: U256) -> Result<bool> {
- // self.consume_store_reads(1)?;
Err("Approve not supported".into())
}
fn balance_of(&self, owner: Address) -> Result<U256> {
- consume_store_reads(self, 1)?;
+ self.consume_store_reads(1)?;
let owner = T::CrossAccountId::from_eth(owner);
let balance = <T as Config>::Currency::free_balance(owner.as_sub());
Ok(balance.into())
@@ -64,7 +49,7 @@
}
fn total_supply(&self) -> Result<U256> {
- consume_store_reads(self, 1)?;
+ self.consume_store_reads(1)?;
let total = <T as Config>::Currency::total_issuance();
Ok(total.into())
}
@@ -111,7 +96,7 @@
T::AccountId: From<[u8; 32]>,
{
fn balance_of_cross(&self, owner: CrossAddress) -> Result<U256> {
- consume_store_reads(self, 1)?;
+ self.consume_store_reads(1)?;
let owner = owner.into_sub_cross_account::<T>()?;
let balance = <T as Config>::Currency::free_balance(owner.as_sub());
Ok(balance.into())
@@ -122,18 +107,13 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = to.into_sub_cross_account::<T>()?;
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- // let budget = self
- // .recorder
- // .weight_calls_budget(<StructureWeight<T>>::find_parent());
+ let budget = self
+ .recorder()
+ .weight_calls_budget(<StructureWeight<T>>::find_parent());
+
+ <Pallet<T>>::transfer(self, &caller, &to, amount, &budget)
+ .map_err(|e| dispatch_to_evm::<T>(e.error))?;
- // <Pallet<T>>::transfer(self, &caller, &to, amount, &budget).map_err(|_| "transfer error")?;
- <T as Config>::Currency::transfer(
- caller.as_sub(),
- to.as_sub(),
- amount,
- ExistenceRequirement::KeepAlive,
- )
- .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -154,19 +134,13 @@
return Err("no permission".into());
}
- // let budget = self
- // .recorder
- // .weight_calls_budget(<StructureWeight<T>>::find_parent());
+ let budget = self
+ .recorder()
+ .weight_calls_budget(<StructureWeight<T>>::find_parent());
+
+ <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)
+ .map_err(|e| dispatch_to_evm::<T>(e.error))?;
- // <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)
- // .map_err(dispatch_to_evm::<T>)?;
- <T as Config>::Currency::transfer(
- caller.as_sub(),
- to.as_sub(),
- amount,
- ExistenceRequirement::KeepAlive,
- )
- .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
}
pallets/balances-adapter/src/lib.rsdiffbeforeafterboth1// #![doc = include_str!("../README.md")]2#![cfg_attr(not(feature = "std"), no_std)]34extern crate alloc;5use core::ops::Deref;67use frame_support::sp_runtime::DispatchResult;8use pallet_evm_coder_substrate::{WithRecorder, SubstrateRecorder};9pub use pallet::*;1011pub mod common;12pub mod erc;1314pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;1516const NATIVE_FUNGIBLE_COLLECTION_ID: up_data_structs::CollectionId =17 up_data_structs::CollectionId(0);1819/// Handle for native fungible collection20pub struct NativeFungibleHandle<T: Config>(SubstrateRecorder<T>);21impl<T: Config> NativeFungibleHandle<T> {22 /// Creates a handle23 pub fn new() -> NativeFungibleHandle<T> {24 Self(SubstrateRecorder::new(u64::MAX))25 }2627 /// Check if the collection is internal28 pub fn check_is_internal(&self) -> DispatchResult {29 Ok(())30 }31}3233impl<T: Config> WithRecorder<T> for NativeFungibleHandle<T> {34 fn recorder(&self) -> &pallet_evm_coder_substrate::SubstrateRecorder<T> {35 &self.036 }37 fn into_recorder(self) -> pallet_evm_coder_substrate::SubstrateRecorder<T> {38 self.039 }40}4142impl<T: Config> Deref for NativeFungibleHandle<T> {43 type Target = SubstrateRecorder<T>;4445 fn deref(&self) -> &Self::Target {46 &self.047 }48}49#[frame_support::pallet]50pub mod pallet {51 use super::*;52 use alloc::string::String;53 use frame_support::{54 dispatch::PostDispatchInfo,55 ensure,56 pallet_prelude::{DispatchResultWithPostInfo, Pays},57 traits::{Currency, ExistenceRequirement, Get},58 };59 use pallet_balances::WeightInfo;60 use pallet_common::{erc::CrossAccountId, Error as CommonError, Pallet as PalletCommon};61 use pallet_structure::Pallet as PalletStructure;62 use sp_core::U256;63 use sp_runtime::DispatchError;64 use up_data_structs::{budget::Budget, mapping::TokenAddressMapping, TokenId};6566 #[pallet::config]67 pub trait Config:68 frame_system::Config69 + pallet_evm_coder_substrate::Config70 + pallet_common::Config71 + pallet_structure::Config72 {73 /// Currency from `pallet_balances`74 type Currency: frame_support::traits::Currency<75 Self::AccountId,76 Balance = Self::CurrencyBalance,77 >;78 /// Balance type of chain79 type CurrencyBalance: Into<U256> + TryFrom<U256> + TryFrom<u128> + Into<u128>;8081 /// Decimals of balance82 type Decimals: Get<u8>;83 /// Collection name84 type Name: Get<String>;85 /// Collection symbol86 type Symbol: Get<String>;8788 /// Weight information89 type WeightInfo: WeightInfo;90 }91 #[pallet::pallet]92 pub struct Pallet<T>(_);9394 impl<T: Config> Pallet<T> {95 /// Checks if a non-owner has (enough) allowance from the owner to perform operations on the tokens.96 /// Returns the expected remaining allowance - it should be set manually if the transaction proceeds.97 ///98 /// - `collection`: Collection that contains the token.99 /// - `spender`: CrossAccountId who has the allowance rights.100 /// - `from`: The owner of the tokens who sets the allowance.101 /// - `amount`: Amount of tokens by which the allowance sholud be reduced.102 fn check_allowed(103 spender: &T::CrossAccountId,104 from: &T::CrossAccountId,105 nesting_budget: &dyn Budget,106 ) -> Result<u128, DispatchError> {107 if let Some((collection_id, token_id)) =108 T::CrossTokenAddressMapping::address_to_token(from)109 {110 ensure!(111 <PalletStructure<T>>::check_indirectly_owned(112 spender.clone(),113 collection_id,114 token_id,115 None,116 nesting_budget117 )?,118 <CommonError<T>>::ApprovedValueTooLow,119 );120 } else if !spender.conv_eq(from) {121 return Ok(0);122 }123124 Ok(<T as Config>::Currency::free_balance(from.as_sub()).into())125 }126127 /// Transfers the specified amount of tokens. Will check that128 /// the transfer is allowed for the token.129 ///130 /// - `from`: Owner of tokens to transfer.131 /// - `to`: Recepient of transfered tokens.132 /// - `amount`: Amount of tokens to transfer.133 /// - `collection`: Collection that contains the token134 pub fn transfer(135 _collection: &NativeFungibleHandle<T>,136 from: &T::CrossAccountId,137 to: &T::CrossAccountId,138 amount: u128,139 nesting_budget: &dyn Budget,140 ) -> DispatchResultWithPostInfo {141 <PalletCommon<T>>::ensure_correct_receiver(to)?;142143 if from != to && amount != 0 {144 <T as Config>::Currency::transfer(145 from.as_sub(),146 to.as_sub(),147 amount148 .try_into()149 .map_err(|_| sp_runtime::ArithmeticError::Overflow)?,150 ExistenceRequirement::KeepAlive,151 )?;152153 <PalletStructure<T>>::nest_if_sent_to_token(154 from.clone(),155 to,156 NATIVE_FUNGIBLE_COLLECTION_ID,157 TokenId::default(),158 nesting_budget,159 )?;160161 let balance_from: u128 =162 <T as Config>::Currency::free_balance(from.as_sub()).into();163 if balance_from == 0 {164 <PalletStructure<T>>::unnest_if_nested(165 from,166 NATIVE_FUNGIBLE_COLLECTION_ID,167 TokenId::default(),168 );169 }170 };171172 Ok(PostDispatchInfo {173 actual_weight: Some(<SelfWeightOf<T>>::transfer()),174 pays_fee: Pays::Yes,175 })176 }177178 pub fn transfer_from(179 collection: &NativeFungibleHandle<T>,180 spender: &T::CrossAccountId,181 from: &T::CrossAccountId,182 to: &T::CrossAccountId,183 amount: u128,184 nesting_budget: &dyn Budget,185 ) -> DispatchResultWithPostInfo {186 let allowance = Self::check_allowed(spender, from, nesting_budget)?;187 if allowance < amount {188 return Err(<CommonError<T>>::ApprovedValueTooLow.into());189 }190 Self::transfer(collection, from, to, amount, nesting_budget)191 }192 }193}pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -77,14 +77,6 @@
fn call(self, handle: &mut impl PrecompileHandle) -> Option<PrecompileResult>;
}
-impl CommonEvmHandler for () {
- const CODE: &'static [u8] = &[];
-
- fn call(self, _handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {
- None
- }
-}
-
/// @title A contract that allows you to work with collections.
#[solidity_interface(name = Collection, enum(derive(PreDispatch)), enum_attr(weight))]
impl<T: Config> CollectionHandle<T>
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -68,7 +68,6 @@
dispatch::Pays,
transactional, fail,
};
-use pallet_evm::GasWeightMapping;
use up_data_structs::{
AccessMode, COLLECTION_NUMBER_LIMIT, Collection, RpcCollection, CollectionFlags,
RpcCollectionFlags, CollectionId, CreateItemData, MAX_TOKEN_PREFIX_LENGTH,
@@ -101,7 +100,7 @@
/// Collection handle contains information about collection data and id.
/// Also provides functionality to count consumed gas.
///
-/// CollectionHandle is used as a generic wrapper for collections of all types.
+/// CollectionHandle is used as a generic wrapper for collections of all types (except native fungible).
/// It allows to perform common operations and queries on any collection type,
/// both completely general for all, as well as their respective implementations of [`CommonCollectionOperations`].
#[must_use = "Should call submit_logs or save, otherwise some data will be lost for evm side"]
@@ -153,7 +152,7 @@
&self,
reads: u64,
) -> pallet_evm_coder_substrate::execution::Result<()> {
- consume_store_reads(self.recorder(), reads)
+ self.recorder().consume_store_reads(reads)
}
/// Consume gas for writing.
@@ -161,7 +160,7 @@
&self,
writes: u64,
) -> pallet_evm_coder_substrate::execution::Result<()> {
- consume_store_writes(self.recorder(), writes)
+ self.recorder().consume_store_writes(writes)
}
/// Consume gas for reading and writing.
@@ -170,7 +169,8 @@
reads: u64,
writes: u64,
) -> pallet_evm_coder_substrate::execution::Result<()> {
- consume_store_reads_and_writes(self.recorder(), reads, writes)
+ self.recorder()
+ .consume_store_reads_and_writes(reads, writes)
}
/// Save collection to storage.
@@ -441,7 +441,7 @@
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
/// Collection id for native fungible collction.
- pub const NATIVE_FINGIBLE_COLLECTION_ID: CollectionId = CollectionId(0);
+ pub const NATIVE_FUNGIBLE_COLLECTION_ID: CollectionId = CollectionId(0);
#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
@@ -2322,48 +2322,4 @@
PropertiesError::EmptyPropertyKey => Self::EmptyPropertyKey,
}
}
-}
-
-/// Consume gas for reading.
-pub fn consume_store_reads<T: Config>(
- recorder: &SubstrateRecorder<T>,
- reads: u64,
-) -> pallet_evm_coder_substrate::execution::Result<()> {
- recorder.consume_gas(T::GasWeightMapping::weight_to_gas(Weight::from_parts(
- <T as frame_system::Config>::DbWeight::get()
- .read
- .saturating_mul(reads),
- // TODO: measure proof
- 0,
- )))
-}
-
-/// Consume gas for writing.
-pub fn consume_store_writes<T: Config>(
- recorder: &SubstrateRecorder<T>,
- writes: u64,
-) -> pallet_evm_coder_substrate::execution::Result<()> {
- recorder.consume_gas(T::GasWeightMapping::weight_to_gas(Weight::from_parts(
- <T as frame_system::Config>::DbWeight::get()
- .write
- .saturating_mul(writes),
- // TODO: measure proof
- 0,
- )))
-}
-
-/// Consume gas for reading and writing.
-pub fn consume_store_reads_and_writes<T: Config>(
- recorder: &SubstrateRecorder<T>,
- reads: u64,
- writes: u64,
-) -> pallet_evm_coder_substrate::execution::Result<()> {
- let weight = <T as frame_system::Config>::DbWeight::get();
- let reads = weight.read.saturating_mul(reads);
- let writes = weight.read.saturating_mul(writes);
- recorder.consume_gas(T::GasWeightMapping::weight_to_gas(Weight::from_parts(
- reads.saturating_add(writes),
- // TODO: measure proof
- 0,
- )))
}
pallets/evm-coder-substrate/src/lib.rsdiffbeforeafterboth--- a/pallets/evm-coder-substrate/src/lib.rs
+++ b/pallets/evm-coder-substrate/src/lib.rs
@@ -37,7 +37,7 @@
ExitError, ExitRevert, ExitSucceed, GasWeightMapping, PrecompileFailure, PrecompileOutput,
PrecompileResult, PrecompileHandle,
};
-use sp_core::H160;
+use sp_core::{Get, H160};
// #[cfg(feature = "runtime-benchmarks")]
// pub mod benchmarking;
pub mod execution;
@@ -204,6 +204,40 @@
Err(Error::Error(e)) => Err(e.into()),
})
}
+
+ /// Consume gas for reading.
+ pub fn consume_store_reads(&self, reads: u64) -> execution::Result<()> {
+ self.consume_gas(T::GasWeightMapping::weight_to_gas(Weight::from_parts(
+ <T as frame_system::Config>::DbWeight::get()
+ .read
+ .saturating_mul(reads),
+ // TODO: measure proof
+ 0,
+ )))
+ }
+
+ /// Consume gas for writing.
+ pub fn consume_store_writes(&self, writes: u64) -> execution::Result<()> {
+ self.consume_gas(T::GasWeightMapping::weight_to_gas(Weight::from_parts(
+ <T as frame_system::Config>::DbWeight::get()
+ .write
+ .saturating_mul(writes),
+ // TODO: measure proof
+ 0,
+ )))
+ }
+
+ /// Consume gas for reading and writing.
+ pub fn consume_store_reads_and_writes(&self, reads: u64, writes: u64) -> execution::Result<()> {
+ let weight = <T as frame_system::Config>::DbWeight::get();
+ let reads = weight.read.saturating_mul(reads);
+ let writes = weight.read.saturating_mul(writes);
+ self.consume_gas(T::GasWeightMapping::weight_to_gas(Weight::from_parts(
+ reads.saturating_add(writes),
+ // TODO: measure proof
+ 0,
+ )))
+ }
}
pub fn dispatch_to_evm<T: Config>(err: DispatchError) -> execution::Error {
pallets/unique/src/lib.rsdiffbeforeafterboth--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -440,7 +440,7 @@
collection_id: CollectionId,
address: T::CrossAccountId,
) -> DispatchResult {
- if collection_id == pallet_common::NATIVE_FINGIBLE_COLLECTION_ID {
+ if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {
fail!(<pallet_common::Error<T>>::UnsupportedOperation);
}
@@ -471,7 +471,7 @@
collection_id: CollectionId,
address: T::CrossAccountId,
) -> DispatchResult {
- if collection_id == pallet_common::NATIVE_FINGIBLE_COLLECTION_ID {
+ if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {
fail!(<pallet_common::Error<T>>::UnsupportedOperation);
}
@@ -501,7 +501,7 @@
collection_id: CollectionId,
new_owner: T::AccountId,
) -> DispatchResult {
- if collection_id == pallet_common::NATIVE_FINGIBLE_COLLECTION_ID {
+ if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {
fail!(<pallet_common::Error<T>>::UnsupportedOperation);
}
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
@@ -533,7 +533,7 @@
collection_id: CollectionId,
new_admin_id: T::CrossAccountId,
) -> DispatchResult {
- if collection_id == pallet_common::NATIVE_FINGIBLE_COLLECTION_ID {
+ if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {
fail!(<pallet_common::Error<T>>::UnsupportedOperation);
}
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
@@ -562,7 +562,7 @@
collection_id: CollectionId,
account_id: T::CrossAccountId,
) -> DispatchResult {
- if collection_id == pallet_common::NATIVE_FINGIBLE_COLLECTION_ID {
+ if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {
fail!(<pallet_common::Error<T>>::UnsupportedOperation);
}
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
@@ -590,7 +590,7 @@
collection_id: CollectionId,
new_sponsor: T::AccountId,
) -> DispatchResult {
- if collection_id == pallet_common::NATIVE_FINGIBLE_COLLECTION_ID {
+ if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {
fail!(<pallet_common::Error<T>>::UnsupportedOperation);
}
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
@@ -617,7 +617,7 @@
origin: OriginFor<T>,
collection_id: CollectionId,
) -> DispatchResult {
- if collection_id == pallet_common::NATIVE_FINGIBLE_COLLECTION_ID {
+ if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {
fail!(<pallet_common::Error<T>>::UnsupportedOperation);
}
let sender = ensure_signed(origin)?;
@@ -640,7 +640,7 @@
origin: OriginFor<T>,
collection_id: CollectionId,
) -> DispatchResult {
- if collection_id == pallet_common::NATIVE_FINGIBLE_COLLECTION_ID {
+ if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {
fail!(<pallet_common::Error<T>>::UnsupportedOperation);
}
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
@@ -920,7 +920,7 @@
collection_id: CollectionId,
value: bool,
) -> DispatchResult {
- if collection_id == pallet_common::NATIVE_FINGIBLE_COLLECTION_ID {
+ if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {
fail!(<pallet_common::Error<T>>::UnsupportedOperation);
}
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
@@ -1175,7 +1175,7 @@
collection_id: CollectionId,
new_limit: CollectionLimits,
) -> DispatchResult {
- if collection_id == pallet_common::NATIVE_FINGIBLE_COLLECTION_ID {
+ if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {
fail!(<pallet_common::Error<T>>::UnsupportedOperation);
}
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
@@ -1202,7 +1202,7 @@
collection_id: CollectionId,
new_permission: CollectionPermissions,
) -> DispatchResult {
- if collection_id == pallet_common::NATIVE_FINGIBLE_COLLECTION_ID {
+ if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {
fail!(<pallet_common::Error<T>>::UnsupportedOperation);
}
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
@@ -1273,7 +1273,7 @@
origin: OriginFor<T>,
collection_id: CollectionId,
) -> DispatchResult {
- if collection_id == pallet_common::NATIVE_FINGIBLE_COLLECTION_ID {
+ if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {
fail!(<pallet_common::Error<T>>::UnsupportedOperation);
}
ensure_root(origin)?;
runtime/common/dispatch.rsdiffbeforeafterboth--- a/runtime/common/dispatch.rs
+++ b/runtime/common/dispatch.rs
@@ -100,12 +100,11 @@
}
fn destroy(sender: T::CrossAccountId, collection_id: CollectionId) -> DispatchResult {
- if collection_id == pallet_common::NATIVE_FINGIBLE_COLLECTION_ID {
+ if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {
fail!(<pallet_common::Error<T>>::UnsupportedOperation);
}
let collection = <CollectionHandle<T>>::try_get(collection_id)?;
- collection.check_is_internal()?;
match collection.mode {
CollectionMode::ReFungible => {
@@ -122,7 +121,7 @@
}
fn dispatch(collection_id: CollectionId) -> Result<Self, DispatchError> {
- if collection_id == CollectionId(0) {
+ if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {
return Ok(Self::NativeFungible(NativeFungibleHandle::new()));
}
@@ -188,7 +187,7 @@
}
fn call(handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {
if let Some(collection_id) = map_eth_to_id(&handle.code_address()) {
- if collection_id == CollectionId(0) {
+ if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {
<NativeFungibleHandle<T>>::new().call(handle)
} else {
let collection = <CollectionHandle<T>>::new_with_gas_limit(