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
7 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;
1212
13frontier_contract! {13frontier_contract! {
63 }63 }
6464
65 fn decimals(&self) -> Result<u8> {65 fn decimals(&self) -> Result<u8> {
66 // Ok(if let CollectionMode::Fungible(decimals) = &self.mode {
67 // *decimals
68 // } else {
69 // unreachable!
70 // })
71
72 // From config 18
73 todo!()66 Ok(T::Decimals::get())
74 }67 }
7568
76 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 }
8272
83 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 }
8776
88 fn total_supply(&self) -> Result<U256> {77 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
--- 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! {