From 32e570b0cd41eaf6c667ff06593bedba0a432e18 Mon Sep 17 00:00:00 2001 From: Jeeyong Um Date: Thu, 10 Oct 2024 17:00:41 +0900 Subject: [PATCH] feat: Allow wrapped babel call with indirect origin (#74) --- frame/babel/src/lib.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/frame/babel/src/lib.rs b/frame/babel/src/lib.rs index 83a26bf6..5fa42fe7 100644 --- a/frame/babel/src/lib.rs +++ b/frame/babel/src/lib.rs @@ -110,8 +110,13 @@ pub mod pallet { transaction: Vec, ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; - let public: ecdsa::Public = who.try_into().map_err(|_| Error::::InvalidOrigin)?; - let address: np_babel::EthereumAddress = public.into(); + let address = T::AddressMap::get(who) + .iter() + .find_map(|address| match address { + VarAddress::Ethereum(address) => Some(address.clone()), + _ => None, + }) + .ok_or(Error::::InvalidOrigin)?; let origin = T::RuntimeOrigin::from(pallet_ethereum::RawOrigin::EthereumTransaction( address.into(), @@ -142,8 +147,13 @@ pub mod pallet { tx_bytes: Vec, ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; - let public: ecdsa::Public = who.try_into().map_err(|_| Error::::InvalidOrigin)?; - let address: np_babel::CosmosAddress = public.into(); + let address = T::AddressMap::get(who) + .iter() + .find_map(|address| match address { + VarAddress::Cosmos(address) => Some(address.clone()), + _ => None, + }) + .ok_or(Error::::InvalidOrigin)?; let tx = Tx::decode(&mut &*tx_bytes).map_err(|_| Error::::InvalidTransaction)?; let signers =