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.rsdiffbeforeafterboth1// #![doc = include_str!("../README.md")]2#![cfg_attr(not(feature = "std"), no_std)]3#![warn(missing_docs)]45pub use pallet::*;67pub mod erc;89#[frame_support::pallet]10pub mod pallet {11 use sp_core::U256;1213 #[pallet::config]14 pub trait Config: frame_system::Config + pallet_evm_coder_substrate::Config {15 type Currency: frame_support::traits::Currency<16 Self::AccountId,17 Balance = Self::CurrencyBalance,18 >;19 type CurrencyBalance: Into<U256>;20 }21 #[pallet::pallet]22 pub struct Pallet<T>(_);2324 #[pallet::call]25 impl<T: Config> Pallet<T> {}26}1// #![doc = include_str!("../README.md")]2#![cfg_attr(not(feature = "std"), no_std)]3#![warn(missing_docs)]45pub use pallet::*;67pub mod erc;89#[frame_support::pallet]10pub mod pallet {11 use frame_support::traits::Get;12 use sp_core::U256;1314 #[pallet::config]15 pub trait Config: frame_system::Config + pallet_evm_coder_substrate::Config {16 type Currency: frame_support::traits::Currency<17 Self::AccountId,18 Balance = Self::CurrencyBalance,19 >;20 type CurrencyBalance: Into<U256>;2122 type Decimals: Get<u8>;23 type Name: Get<String>;24 type Symbol: Get<String>;25 }26 #[pallet::pallet]27 pub struct Pallet<T>(_);2829 #[pallet::call]30 impl<T: Config> Pallet<T> {}31}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! {