Skip to content

Commit

Permalink
feat: Allow wrapped babel call with indirect origin (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
conr2d authored Oct 10, 2024
1 parent ff2b80c commit 32e570b
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions frame/babel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,13 @@ pub mod pallet {
transaction: Vec<u8>,
) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?;
let public: ecdsa::Public = who.try_into().map_err(|_| Error::<T>::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::<T>::InvalidOrigin)?;

let origin = T::RuntimeOrigin::from(pallet_ethereum::RawOrigin::EthereumTransaction(
address.into(),
Expand Down Expand Up @@ -142,8 +147,13 @@ pub mod pallet {
tx_bytes: Vec<u8>,
) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?;
let public: ecdsa::Public = who.try_into().map_err(|_| Error::<T>::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::<T>::InvalidOrigin)?;

let tx = Tx::decode(&mut &*tx_bytes).map_err(|_| Error::<T>::InvalidTransaction)?;
let signers =
Expand Down

0 comments on commit 32e570b

Please sign in to comment.