--- a/pallets/balances-adapter/src/erc.rs +++ b/pallets/balances-adapter/src/erc.rs @@ -7,7 +7,7 @@ execution::{PreDispatch, Result}, frontier_contract, WithRecorder, SubstrateRecorder, }; -use sp_core::{U256}; +use sp_core::{U256, Get}; use sp_std::vec::Vec; frontier_contract! { @@ -63,26 +63,15 @@ } fn decimals(&self) -> Result { - // Ok(if let CollectionMode::Fungible(decimals) = &self.mode { - // *decimals - // } else { - // unreachable! - // }) - - // From config 18 - todo!() + Ok(T::Decimals::get()) } fn name(&self) -> Result { - // Ok(decode_utf16(self.name.iter().copied()) - // .map(|r| r.unwrap_or(REPLACEMENT_CHARACTER)) - // .collect::()) - todo!() + Ok(T::Name::get()) } fn symbol(&self) -> Result { - // Ok(String::from_utf8_lossy(&self.token_prefix).into()) - todo!() + Ok(T::Symbol::get()) } fn total_supply(&self) -> Result { --- a/pallets/balances-adapter/src/lib.rs +++ b/pallets/balances-adapter/src/lib.rs @@ -8,6 +8,7 @@ #[frame_support::pallet] pub mod pallet { + use frame_support::traits::Get; use sp_core::U256; #[pallet::config] @@ -17,6 +18,10 @@ Balance = Self::CurrencyBalance, >; type CurrencyBalance: Into; + + type Decimals: Get; + type Name: Get; + type Symbol: Get; } #[pallet::pallet] pub struct Pallet(_); --- a/runtime/common/config/pallets/mod.rs +++ b/runtime/common/config/pallets/mod.rs @@ -23,7 +23,7 @@ weights::CommonWeights, RelayChainBlockNumberProvider, }, - Runtime, RuntimeEvent, RuntimeCall, RuntimeOrigin, Balances, + Runtime, RuntimeEvent, RuntimeCall, RuntimeOrigin, RUNTIME_NAME, TOKEN_SYMBOL, Balances, }; use frame_support::traits::{ConstU32, ConstU64, Currency}; use up_common::{ @@ -51,8 +51,11 @@ pub mod preimage; parameter_types! { + pub const CollectionCreationPrice: Balance = 2 * UNIQUE; + pub const Decimals: u8 = 32; pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account_truncating(); - pub const CollectionCreationPrice: Balance = 2 * UNIQUE; + pub Name: String = RUNTIME_NAME.to_string(); + pub Symbol: String = TOKEN_SYMBOL.to_string(); } impl pallet_common::Config for Runtime { @@ -86,6 +89,9 @@ impl pallet_balances_adapter::Config for Runtime { type Currency = Balances; type CurrencyBalance = >::Balance; + type Decimals = Decimals; + type Name = Name; + type Symbol = Symbol; } parameter_types! {