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
88
9#[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;
1213
13 #[pallet::config]14 #[pallet::config]
18 >;19 >;
19 type CurrencyBalance: Into<U256>;20 type CurrencyBalance: Into<U256>;
21
22 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>(_);
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! {