difftreelog
feat impl decimals, name, symbol
in: master
3 files changed
pallets/balances-adapter/src/erc.rsdiffbeforeafterboth--- 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<u8> {
- // Ok(if let CollectionMode::Fungible(decimals) = &self.mode {
- // *decimals
- // } else {
- // unreachable!
- // })
-
- // From config 18
- todo!()
+ Ok(T::Decimals::get())
}
fn name(&self) -> Result<String> {
- // Ok(decode_utf16(self.name.iter().copied())
- // .map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))
- // .collect::<String>())
- todo!()
+ Ok(T::Name::get())
}
fn symbol(&self) -> Result<String> {
- // Ok(String::from_utf8_lossy(&self.token_prefix).into())
- todo!()
+ Ok(T::Symbol::get())
}
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.rsdiffbeforeafterboth--- 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 = <Balances as Currency<Self::AccountId>>::Balance;
+ type Decimals = Decimals;
+ type Name = Name;
+ type Symbol = Symbol;
}
parameter_types! {