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

Remove useless type in evm pallet #729

Merged
merged 2 commits into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions bin/node/runtime/pangolin/src/pallets/evm_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ impl Config for Runtime {
type AddressMapping = ConcatAddressMapping<Self::AccountId>;
type FindAuthor = EthereumFindAuthor<Babe>;
type BlockHashMapping = EthereumBlockHashMapping<Self>;
type RingCurrency = Ring;
type KtonCurrency = Kton;
type Event = Event;
type Precompiles = PangolinPrecompiles<Self>;
type ChainId = ChainId;
Expand Down
2 changes: 0 additions & 2 deletions frame/bridge/s2s/issuing/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ impl darwinia_evm::Config for Test {
type GasWeightMapping = ();
type CallOrigin = EnsureAddressTruncated<Self::AccountId>;
type AddressMapping = HashedAddressMapping;
type RingCurrency = Ring;
type KtonCurrency = Kton;
type Event = ();
type Precompiles = ();
type FindAuthor = ();
Expand Down
2 changes: 0 additions & 2 deletions frame/dvm/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ impl darwinia_evm::Config for Test {
type GasWeightMapping = ();
type CallOrigin = EnsureAddressTruncated<Self::AccountId>;
type AddressMapping = HashedAddressMapping;
type RingCurrency = Ring;
type KtonCurrency = Kton;
type Event = ();
type Precompiles = MockPrecompiles<Self>;
type ChainId = ChainId;
Expand Down
5 changes: 1 addition & 4 deletions frame/dvm/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,7 @@ macro_rules! assert_balance {
<Test as darwinia_evm::Config>::RingAccountBasic::account_basic(&$evm_address).balance,
$balance
);
assert_eq!(
<Test as darwinia_evm::Config>::RingCurrency::free_balance(&account_id),
$left
);
assert_eq!(Ring::free_balance(&account_id), $left);
assert_eq!(
<RingRemainBalance as RemainBalanceOp<Test, u64>>::remaining_balance(&account_id),
$right
Expand Down
8 changes: 2 additions & 6 deletions frame/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use evm::{Config as EvmConfig, ExitError, ExitReason};
use serde::{Deserialize, Serialize};
// --- paritytech ---
use frame_support::{
traits::{Currency, FindAuthor},
traits::FindAuthor,
weights::{PostDispatchInfo, Weight},
};
use frame_system::RawOrigin;
Expand Down Expand Up @@ -86,11 +86,7 @@ pub mod pallet {
/// Find author for the current block.
type FindAuthor: FindAuthor<H160>;

/// Ring Currency type
type RingCurrency: Currency<Self::AccountId>;
/// Kton Currency type
type KtonCurrency: Currency<Self::AccountId>;
/// The account basic mapping way
/// Account basic
type RingAccountBasic: AccountBasic<Self>;
type KtonAccountBasic: AccountBasic<Self>;

Expand Down
30 changes: 3 additions & 27 deletions frame/evm/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,30 +121,11 @@ impl FindAuthor<H160> for FindAuthorTruncated {
pub struct RawAccountBasic<T>(sp_std::marker::PhantomData<T>);
impl<T: Config> AccountBasic<T> for RawAccountBasic<T> {
/// Get the account basic in EVM format.
fn account_basic(address: &H160) -> Account {
let account_id = T::AddressMapping::into_account_id(*address);

let nonce = <frame_system::Pallet<T>>::account_nonce(&account_id);
let balance = T::RingCurrency::free_balance(&account_id);

Account {
nonce: U256::from(UniqueSaturatedInto::<u128>::unique_saturated_into(nonce)),
balance: U256::from(UniqueSaturatedInto::<u128>::unique_saturated_into(balance)),
}
fn account_basic(_address: &H160) -> Account {
Account::default()
}

fn mutate_account_basic_balance(address: &H160, new_balance: U256) {
let account_id = T::AddressMapping::into_account_id(*address);
let current = T::RingAccountBasic::account_basic(address);

if current.balance > new_balance {
let diff = current.balance - new_balance;
T::RingCurrency::slash(&account_id, diff.low_u128().unique_saturated_into());
} else if current.balance < new_balance {
let diff = new_balance - current.balance;
T::RingCurrency::deposit_creating(&account_id, diff.low_u128().unique_saturated_into());
}
}
fn mutate_account_basic_balance(_address: &H160, _new_balance: U256) {}

fn transfer(_source: &H160, _target: &H160, _value: U256) -> Result<(), ExitError> {
Ok(())
Expand Down Expand Up @@ -176,14 +157,9 @@ impl Config for Test {
type FeeCalculator = FixedGasPrice;
type GasWeightMapping = ();
type CallOrigin = EnsureAddressRoot<Self::AccountId>;

type AddressMapping = ConcatAddressMapping<Self::AccountId>;
type BlockHashMapping = SubstrateBlockHashMapping<Self>;
type FindAuthor = FindAuthorTruncated;

type RingCurrency = Ring;
type KtonCurrency = Kton;

type Event = Event;
type Precompiles = ();
type ChainId = ();
Expand Down