Skip to content
This repository was archived by the owner on Mar 13, 2023. It is now read-only.

Commit 77362e1

Browse files
author
bear
authored
Remove useless type in evm pallet (#729)
* Remove useless types in evm pallet * Update test files
1 parent 37fea41 commit 77362e1

File tree

7 files changed

+9
-46
lines changed

7 files changed

+9
-46
lines changed

Cargo.lock

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/node/runtime/pangolin/src/pallets/evm_.rs

-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ impl Config for Runtime {
8282
type AddressMapping = ConcatAddressMapping<Self::AccountId>;
8383
type FindAuthor = EthereumFindAuthor<Babe>;
8484
type BlockHashMapping = EthereumBlockHashMapping<Self>;
85-
type RingCurrency = Ring;
86-
type KtonCurrency = Kton;
8785
type Event = Event;
8886
type Precompiles = PangolinPrecompiles<Self>;
8987
type ChainId = ChainId;

frame/bridge/s2s/issuing/src/tests.rs

-2
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ impl darwinia_evm::Config for Test {
138138
type GasWeightMapping = ();
139139
type CallOrigin = EnsureAddressTruncated<Self::AccountId>;
140140
type AddressMapping = HashedAddressMapping;
141-
type RingCurrency = Ring;
142-
type KtonCurrency = Kton;
143141
type Event = ();
144142
type Precompiles = ();
145143
type FindAuthor = ();

frame/dvm/src/mock.rs

-2
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,6 @@ impl darwinia_evm::Config for Test {
187187
type GasWeightMapping = ();
188188
type CallOrigin = EnsureAddressTruncated<Self::AccountId>;
189189
type AddressMapping = HashedAddressMapping;
190-
type RingCurrency = Ring;
191-
type KtonCurrency = Kton;
192190
type Event = ();
193191
type Precompiles = MockPrecompiles<Self>;
194192
type ChainId = ChainId;

frame/dvm/src/tests.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,7 @@ macro_rules! assert_balance {
220220
<Test as darwinia_evm::Config>::RingAccountBasic::account_basic(&$evm_address).balance,
221221
$balance
222222
);
223-
assert_eq!(
224-
<Test as darwinia_evm::Config>::RingCurrency::free_balance(&account_id),
225-
$left
226-
);
223+
assert_eq!(Ring::free_balance(&account_id), $left);
227224
assert_eq!(
228225
<RingRemainBalance as RemainBalanceOp<Test, u64>>::remaining_balance(&account_id),
229226
$right

frame/evm/src/lib.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use evm::{Config as EvmConfig, ExitError, ExitReason};
4242
use serde::{Deserialize, Serialize};
4343
// --- paritytech ---
4444
use frame_support::{
45-
traits::{Currency, FindAuthor},
45+
traits::FindAuthor,
4646
weights::{PostDispatchInfo, Weight},
4747
};
4848
use frame_system::RawOrigin;
@@ -86,11 +86,7 @@ pub mod pallet {
8686
/// Find author for the current block.
8787
type FindAuthor: FindAuthor<H160>;
8888

89-
/// Ring Currency type
90-
type RingCurrency: Currency<Self::AccountId>;
91-
/// Kton Currency type
92-
type KtonCurrency: Currency<Self::AccountId>;
93-
/// The account basic mapping way
89+
/// Account basic
9490
type RingAccountBasic: AccountBasic<Self>;
9591
type KtonAccountBasic: AccountBasic<Self>;
9692

frame/evm/src/tests.rs

+3-27
Original file line numberDiff line numberDiff line change
@@ -121,30 +121,11 @@ impl FindAuthor<H160> for FindAuthorTruncated {
121121
pub struct RawAccountBasic<T>(sp_std::marker::PhantomData<T>);
122122
impl<T: Config> AccountBasic<T> for RawAccountBasic<T> {
123123
/// Get the account basic in EVM format.
124-
fn account_basic(address: &H160) -> Account {
125-
let account_id = T::AddressMapping::into_account_id(*address);
126-
127-
let nonce = <frame_system::Pallet<T>>::account_nonce(&account_id);
128-
let balance = T::RingCurrency::free_balance(&account_id);
129-
130-
Account {
131-
nonce: U256::from(UniqueSaturatedInto::<u128>::unique_saturated_into(nonce)),
132-
balance: U256::from(UniqueSaturatedInto::<u128>::unique_saturated_into(balance)),
133-
}
124+
fn account_basic(_address: &H160) -> Account {
125+
Account::default()
134126
}
135127

136-
fn mutate_account_basic_balance(address: &H160, new_balance: U256) {
137-
let account_id = T::AddressMapping::into_account_id(*address);
138-
let current = T::RingAccountBasic::account_basic(address);
139-
140-
if current.balance > new_balance {
141-
let diff = current.balance - new_balance;
142-
T::RingCurrency::slash(&account_id, diff.low_u128().unique_saturated_into());
143-
} else if current.balance < new_balance {
144-
let diff = new_balance - current.balance;
145-
T::RingCurrency::deposit_creating(&account_id, diff.low_u128().unique_saturated_into());
146-
}
147-
}
128+
fn mutate_account_basic_balance(_address: &H160, _new_balance: U256) {}
148129

149130
fn transfer(_source: &H160, _target: &H160, _value: U256) -> Result<(), ExitError> {
150131
Ok(())
@@ -176,14 +157,9 @@ impl Config for Test {
176157
type FeeCalculator = FixedGasPrice;
177158
type GasWeightMapping = ();
178159
type CallOrigin = EnsureAddressRoot<Self::AccountId>;
179-
180160
type AddressMapping = ConcatAddressMapping<Self::AccountId>;
181161
type BlockHashMapping = SubstrateBlockHashMapping<Self>;
182162
type FindAuthor = FindAuthorTruncated;
183-
184-
type RingCurrency = Ring;
185-
type KtonCurrency = Kton;
186-
187163
type Event = Event;
188164
type Precompiles = ();
189165
type ChainId = ();

0 commit comments

Comments
 (0)