From 2609aecaee6958b67fbdaf63a61bda6ab4722428 Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Tue, 26 Sep 2023 18:49:36 +0530 Subject: [PATCH] fix: benchmarks --- pallets/unified-accounts/src/benchmarking.rs | 6 ++---- pallets/unified-accounts/src/lib.rs | 8 ++++++-- pallets/unified-accounts/src/tests.rs | 10 ++++++++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/pallets/unified-accounts/src/benchmarking.rs b/pallets/unified-accounts/src/benchmarking.rs index e69aa8fa77..b86e3ad425 100644 --- a/pallets/unified-accounts/src/benchmarking.rs +++ b/pallets/unified-accounts/src/benchmarking.rs @@ -27,9 +27,7 @@ fn assert_last_event(generic_event: ::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); } -#[benchmarks( - where <::SignatureHelper as SignatureHelper>::Signature: IsType<[u8;65]> -)] +#[benchmarks] mod benchmarks { use super::*; @@ -39,7 +37,7 @@ mod benchmarks { let eth_secret_key = libsecp256k1::SecretKey::parse(&keccak_256(b"Alice")).unwrap(); let evm_address = Pallet::::eth_address(ð_secret_key); let signature = Pallet::::eth_sign_prehash( - &T::SignatureHelper::build_signing_payload(&caller), + &Pallet::::build_signing_payload(&caller), ð_secret_key, ) .into(); diff --git a/pallets/unified-accounts/src/lib.rs b/pallets/unified-accounts/src/lib.rs index 6ee0ad41c8..19dbced7ba 100644 --- a/pallets/unified-accounts/src/lib.rs +++ b/pallets/unified-accounts/src/lib.rs @@ -39,10 +39,15 @@ //! * `claim_default_evm_address`: Creates the double mapping with default evm address given that //! no prior mapping exists. //! +//! WARNINGS: +//! * This pallet only handles transfer of native balance only, for the rest of native assets +//! hold by evm address like XC20, DAppStaking unclaimed rewards, etc should be transferred +//! manually beforehand by user himself otherwise FUNDS WILL BE LOST FOREVER. +//! * Once mapping is created it cannot be changed. +//! //! ## Traits //! //! * `UnifiedAddressMapper`: Interface to access pallet's mappings with defaults -//! * `SignatureHelper`: Signature verification scheme for proving address ownership //! //! ## Implementations //! @@ -53,7 +58,6 @@ //! for account id mappings to h160. //! * `KillAccountMapping`: [`OnKilledAccount`](frame_support::traits::OnKilledAccount) implementation to remove //! the mappings from storage after account is reaped. -//! * `EIP712Signature`: EIP712 signature implementation for [`SignatureHelper`](crate::SignatureHelper) #![cfg_attr(not(feature = "std"), no_std)] diff --git a/pallets/unified-accounts/src/tests.rs b/pallets/unified-accounts/src/tests.rs index f3d8ff2ed9..4e92a04322 100644 --- a/pallets/unified-accounts/src/tests.rs +++ b/pallets/unified-accounts/src/tests.rs @@ -237,6 +237,16 @@ fn account_default_claim_should_not_work_if_collision() { UnifiedAccounts::claim_default_evm_address(RuntimeOrigin::signed(BOB)), Error::::AlreadyMapped ); + + // check mappings are consistent + assert_eq!( + >::to_h160(&ALICE), + Some(bob_default_h160) + ); + assert_eq!( + >::to_account_id(&bob_default_h160), + Some(ALICE) + ); }); }