Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Use H160 as AccountId #230

Merged
merged 7 commits into from
Nov 30, 2022
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
131 changes: 121 additions & 10 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 modules/dispatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ mod tests {
prepare_root_message(RuntimeCall::System(frame_system::Call::remark {
remark: vec![1, 2, 3],
}));

let weight = message.weight;
message.dispatch_fee_payment = DispatchFeePayment::AtTargetChain;

Expand Down
4 changes: 4 additions & 0 deletions primitives/darwinia-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ version = "0.1.0"
# crates.io
parity-scale-codec = { version = "3.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
# moonbeam
account = { default-features = false, git = "https://github.com/darwinia-network/moonbeam", branch = "polkadot-v0.9.30" }
# paritytech
bp-messages = { default-features = false, path = "../messages" }
bp-runtime = { default-features = false, path = "../runtime" }
Expand All @@ -25,6 +27,8 @@ std = [
# crates.io
"parity-scale-codec/std",
"scale-info/std",
# moonbeam
"account/std",
# paritytech
"bp-messages/std",
"bp-runtime/std",
Expand Down
13 changes: 8 additions & 5 deletions primitives/darwinia-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#![cfg_attr(not(feature = "std"), no_std)]

mod copy_paste_from_darwinia {
// moonbeam
use account::EthereumSignature;
// paritytech
use frame_support::{
dispatch::DispatchClass,
Expand All @@ -32,16 +34,16 @@ mod copy_paste_from_darwinia {
use sp_runtime::{
generic,
traits::{BlakeTwo256, IdentifyAccount, Verify},
MultiAddress, MultiSignature, OpaqueExtrinsic, Perbill,
OpaqueExtrinsic, Perbill,
};

pub type BlockNumber = u32;
pub type Hashing = BlakeTwo256;
pub type Hash = H256;
pub type Signature = MultiSignature;
pub type Signature = EthereumSignature;
pub type AccountPublic = <Signature as Verify>::Signer;
pub type AccountId = <AccountPublic as IdentifyAccount>::AccountId;
pub type Address = MultiAddress<AccountId, ()>;
pub type Address = AccountId;
pub type Nonce = u32;
pub type Balance = u128;
pub type Header = generic::Header<BlockNumber, Hashing>;
Expand Down Expand Up @@ -105,7 +107,7 @@ use frame_support::{
unsigned::{TransactionValidityError, UnknownTransaction},
weights::Weight,
};
use sp_core::H256;
use sp_core::{H160, H256};
use sp_runtime::{
generic,
generic::Era,
Expand Down Expand Up @@ -263,6 +265,7 @@ impl Chain for DarwiniaLike {
pub struct AccountIdConverter;
impl Convert<H256, AccountId> for AccountIdConverter {
fn convert(hash: H256) -> AccountId {
hash.to_fixed_bytes().into()
let evm_address: H160 = hash.into();
evm_address.into()
}
}
2 changes: 1 addition & 1 deletion primitives/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use frame_support::{
log, pallet_prelude::DispatchResult, PalletError, RuntimeDebug, StorageHasher, StorageValue,
};
use frame_system::RawOrigin;
use sp_core::{hash::H256, storage::StorageKey};
use sp_core::{storage::StorageKey, H256};
use sp_io::hashing::blake2_256;
use sp_runtime::{
traits::{BadOrigin, Header as HeaderT},
Expand Down