difftreelog
feat impl decimals, name, symbol
in: master
3 files changed
pallets/balances-adapter/src/erc.rsdiffbeforeafterboth7 execution::{PreDispatch, Result},7 execution::{PreDispatch, Result},8 frontier_contract, WithRecorder, SubstrateRecorder,8 frontier_contract, WithRecorder, SubstrateRecorder,9};9};10use sp_core::{U256};10use sp_core::{U256, Get};11use sp_std::vec::Vec;11use sp_std::vec::Vec;121213frontier_contract! {13frontier_contract! {63 }63 }646465 fn decimals(&self) -> Result<u8> {65 fn decimals(&self) -> Result<u8> {66 // Ok(if let CollectionMode::Fungible(decimals) = &self.mode {67 // *decimals68 // } else {69 // unreachable!70 // })7172 // From config 1873 todo!()66 Ok(T::Decimals::get())74 }67 }756876 fn name(&self) -> Result<String> {69 fn name(&self) -> Result<String> {77 // Ok(decode_utf16(self.name.iter().copied())78 // .map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))79 // .collect::<String>())80 todo!()70 Ok(T::Name::get())81 }71 }827283 fn symbol(&self) -> Result<String> {73 fn symbol(&self) -> Result<String> {84 // Ok(String::from_utf8_lossy(&self.token_prefix).into())85 todo!()74 Ok(T::Symbol::get())86 }75 }877688 fn total_supply(&self) -> Result<U256> {77 fn total_supply(&self) -> Result<U256> {pallets/balances-adapter/src/lib.rsdiffbeforeafterboth889#[frame_support::pallet]9#[frame_support::pallet]10pub mod pallet {10pub mod pallet {11 use frame_support::traits::Get;11 use sp_core::U256;12 use sp_core::U256;121313 #[pallet::config]14 #[pallet::config]18 >;19 >;19 type CurrencyBalance: Into<U256>;20 type CurrencyBalance: Into<U256>;2122 type Decimals: Get<u8>;23 type Name: Get<String>;24 type Symbol: Get<String>;20 }25 }21 #[pallet::pallet]26 #[pallet::pallet]22 pub struct Pallet<T>(_);27 pub struct Pallet<T>(_);runtime/common/config/pallets/mod.rsdiffbeforeafterboth23 weights::CommonWeights,23 weights::CommonWeights,24 RelayChainBlockNumberProvider,24 RelayChainBlockNumberProvider,25 },25 },26 Runtime, RuntimeEvent, RuntimeCall, RuntimeOrigin, Balances,26 Runtime, RuntimeEvent, RuntimeCall, RuntimeOrigin, RUNTIME_NAME, TOKEN_SYMBOL, Balances,27};27};28use frame_support::traits::{ConstU32, ConstU64, Currency};28use frame_support::traits::{ConstU32, ConstU64, Currency};29use up_common::{29use up_common::{51pub mod preimage;51pub mod preimage;525253parameter_types! {53parameter_types! {54 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;55 pub const Decimals: u8 = 32;54 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account_truncating();56 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account_truncating();55 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;57 pub Name: String = RUNTIME_NAME.to_string();58 pub Symbol: String = TOKEN_SYMBOL.to_string();56}59}576058impl pallet_common::Config for Runtime {61impl pallet_common::Config for Runtime {86impl pallet_balances_adapter::Config for Runtime {89impl pallet_balances_adapter::Config for Runtime {87 type Currency = Balances;90 type Currency = Balances;88 type CurrencyBalance = <Balances as Currency<Self::AccountId>>::Balance;91 type CurrencyBalance = <Balances as Currency<Self::AccountId>>::Balance;92 type Decimals = Decimals;93 type Name = Name;94 type Symbol = Symbol;89}95}909691parameter_types! {97parameter_types! {