Skip to content
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
2 changes: 2 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ num-traits = { version = "0.2", default-features = false }
num_enum = { version = "0.7", default-features = false }
numtoa = { version = "0.2", default-features = false }
once_cell = { version = "1", default-features = false }
paste = { version = "1.0", default-features = false }
proc-macro2 = { version = "1", default-features = false }
qr2term = { version = "0.3", default-features = false }
quote = { version = "1.0", default-features = false }
Expand Down
2 changes: 2 additions & 0 deletions crates/pallet-evm-balances/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ sp-std = { workspace = true }
pallet-evm-system = { path = "../pallet-evm-system", features = ["default"] }

fp-evm = { workspace = true }
hex-literal = { workspace = true }
pallet-evm = { workspace = true }
pallet-timestamp = { workspace = true }
paste = { workspace = true }
sp-core = { workspace = true }
sp-io = { workspace = true }

Expand Down
39 changes: 28 additions & 11 deletions crates/pallet-evm-balances/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use frame_support::{
traits::{ConstU32, ConstU64, FindAuthor},
weights::Weight,
};
use pallet_evm::{EnsureAddressNever, FixedGasWeightMapping, IdentityAddressMapping};
use pallet_evm::{AddressMapping, EnsureAddressNever, FixedGasWeightMapping};
use sp_core::{H160, H256, U256};
use sp_runtime::{
generic,
Expand All @@ -18,12 +18,29 @@ use crate::{self as pallet_evm_balances, *};

pub(crate) const INIT_BALANCE: u64 = 10_000_000_000_000_000;

pub(crate) fn alice() -> H160 {
H160::from_str("1000000000000000000000000000000000000000").unwrap()
}
/// Alice account.
pub const ALICE: u64 = 0x5234;

/// Alice H160 account.
pub const ALICE_H160: H160 = H160(hex_literal::hex!(
"0000000000000000000000000000000000005234"
));

/// Bob account.
pub const BOB: u64 = 0x4235;

/// Bob H160 account.
pub const BOB_H160: H160 = H160(hex_literal::hex!(
"0000000000000000000000000000000000004235"
));

pub(crate) fn bob() -> H160 {
H160::from_str("2000000000000000000000000000000000000000").unwrap()
/// H160 into u64 address mapper.
pub struct H160IntoU64;

impl AddressMapping<u64> for H160IntoU64 {
fn into_account_id(address: H160) -> u64 {
address.to_low_u64_be()
}
}

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
Expand Down Expand Up @@ -72,7 +89,7 @@ impl frame_system::Config for Test {

impl pallet_evm_system::Config for Test {
type RuntimeEvent = RuntimeEvent;
type AccountId = H160;
type AccountId = u64;
type Index = u64;
type AccountData = AccountData<u64>;
type OnNewAccount = ();
Expand All @@ -81,7 +98,7 @@ impl pallet_evm_system::Config for Test {

impl pallet_evm_balances::Config for Test {
type RuntimeEvent = RuntimeEvent;
type AccountId = H160;
type AccountId = u64;
type Balance = u64;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = EvmSystem;
Expand Down Expand Up @@ -137,7 +154,7 @@ impl pallet_evm::Config for Test {
EnsureAddressNever<<Self::AccountProvider as pallet_evm::AccountProvider>::AccountId>;
type WithdrawOrigin =
EnsureAddressNever<<Self::AccountProvider as pallet_evm::AccountProvider>::AccountId>;
type AddressMapping = IdentityAddressMapping;
type AddressMapping = H160IntoU64;
type Currency = EvmBalances;
type RuntimeEvent = RuntimeEvent;
type PrecompilesType = ();
Expand Down Expand Up @@ -167,8 +184,8 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
nonce: Default::default(),
storage: Default::default(),
};
map.insert(alice(), init_genesis_account.clone());
map.insert(bob(), init_genesis_account);
map.insert(ALICE_H160, init_genesis_account.clone());
map.insert(BOB_H160, init_genesis_account);
map
},
},
Expand Down
Loading
Loading