git.delta.rocks / unique-network / refs/commits / 0ccc9eaba8ef

difftreelog

feat impl decimals, name, symbol

Trubnikov Sergey2023-04-20parent: #d5c411b.patch.diff
in: master

3 files changed

modifiedpallets/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> {
modifiedpallets/balances-adapter/src/lib.rsdiffbeforeafterboth
--- 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<U256>;
+
+		type Decimals: Get<u8>;
+		type Name: Get<String>;
+		type Symbol: Get<String>;
 	}
 	#[pallet::pallet]
 	pub struct Pallet<T>(_);
modifiedruntime/common/config/pallets/mod.rsdiffbeforeafterboth
23 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;
5252
53parameter_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}
5760
58impl 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}
9096
91parameter_types! {97parameter_types! {