diff --git a/frame/dvm/src/mock.rs b/frame/dvm/src/mock.rs index ce9c1aabac..ba5ffb6b48 100644 --- a/frame/dvm/src/mock.rs +++ b/frame/dvm/src/mock.rs @@ -22,17 +22,20 @@ use crate::{ *, }; use codec::{Decode, Encode}; -use darwinia_evm::{AddressMapping, EnsureAddressTruncated, FeeCalculator, IssuingHandler}; +use darwinia_evm::{AddressMapping, EnsureAddressTruncated, FeeCalculator}; +use dp_evm::Precompile; use ethereum::{TransactionAction, TransactionSignature}; -use frame_support::{traits::GenesisBuild, ConsensusEngineId, PalletId}; +use evm::{Context, ExitError, ExitSucceed}; +use frame_support::{traits::GenesisBuild, ConsensusEngineId}; use frame_system::mocking::*; use rlp::*; use sp_core::{H160, H256, U256}; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, - AccountId32, DispatchResult, Perbill, RuntimeDebug, + AccountId32, Perbill, RuntimeDebug, }; +use sp_std::{marker::PhantomData, vec::Vec}; darwinia_support::impl_test_account_data! {} @@ -136,7 +139,6 @@ impl FindAuthor for EthereumFindAuthor { frame_support::parameter_types! { pub const TransactionByteFee: u64 = 1; pub const ChainId: u64 = 42; - pub const EVMPalletId: PalletId = PalletId(*b"py/evmpa"); pub const BlockGasLimit: U256 = U256::MAX; } @@ -150,6 +152,17 @@ impl AddressMapping for HashedAddressMapping { } } +pub struct RingBack(PhantomData); +impl Precompile for RingBack { + fn execute( + input: &[u8], + target_gas: Option, + context: &Context, + ) -> core::result::Result<(ExitSucceed, Vec, u64), ExitError> { + darwinia_evm_precompile_transfer::ring::RingBack::::transfer(&input, target_gas, context) + } +} + impl darwinia_evm::Config for Test { type FeeCalculator = FixedGasPrice; type GasWeightMapping = (); @@ -163,7 +176,7 @@ impl darwinia_evm::Config for Test { darwinia_evm_precompile_simple::Sha256, darwinia_evm_precompile_simple::Ripemd160, darwinia_evm_precompile_simple::Identity, - darwinia_evm_precompile_withdraw::WithDraw, + RingBack, ); type ChainId = ChainId; type BlockGasLimit = BlockGasLimit; @@ -173,7 +186,7 @@ impl darwinia_evm::Config for Test { type IssuingHandler = (); } -impl Config for Test { +impl dvm_ethereum::Config for Test { type Event = (); type FindAuthor = EthereumFindAuthor; type StateRoot = IntermediateStateRoot; diff --git a/frame/evm/precompile/contracts/transfer/src/lib.rs b/frame/evm/precompile/contracts/transfer/src/lib.rs index 27f385b58d..b21a02b3de 100644 --- a/frame/evm/precompile/contracts/transfer/src/lib.rs +++ b/frame/evm/precompile/contracts/transfer/src/lib.rs @@ -18,8 +18,8 @@ #![cfg_attr(not(feature = "std"), no_std)] -mod kton; -mod ring; +pub mod kton; +pub mod ring; pub mod util; // --- substrate --- @@ -37,7 +37,6 @@ pub type AccountId = ::AccountId; /// Transfer Precompile Contract, used to support the exchange of KTON and RING tranfer. /// /// The contract address: 0000000000000000000000000000000000000015 -#[derive(PartialEq, Eq, Debug)] pub enum Transfer { /// Transfer RING bach from dvm to darwinia RingBack, diff --git a/frame/evm/precompile/contracts/transfer/src/ring.rs b/frame/evm/precompile/contracts/transfer/src/ring.rs index 4e7fff2ac8..a755872004 100644 --- a/frame/evm/precompile/contracts/transfer/src/ring.rs +++ b/frame/evm/precompile/contracts/transfer/src/ring.rs @@ -21,7 +21,7 @@ impl RingBack { /// 2. transfer from the contract address to withdrawal address /// /// Input data: 32-bit substrate withdrawal public key - pub(crate) fn transfer( + pub fn transfer( input: &[u8], _: Option, context: &Context,