Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Commit

Permalink
refactor: Refactor check_self_contained in pallet-cosmos
Browse files Browse the repository at this point in the history
  • Loading branch information
code0xff committed Sep 12, 2024
1 parent c540129 commit 55ad1ac
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions frame/cosmos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,13 @@ where
pub fn check_self_contained(&self) -> Option<Result<H160, TransactionValidityError>> {
if let Call::transact { tx_bytes } = self {
let check = || {
let (_hrp, address_raw) = Tx::decode(&mut &tx_bytes[..])
.map(|tx| T::SigVerifiableTx::fee_payer(&tx))
.map_err(|_| TransactionValidityError::Invalid(InvalidTransaction::Call))?
.map(|fee_payer| acc_address_from_bech32(&fee_payer))
.map_err(|_| TransactionValidityError::Invalid(InvalidTransaction::BadSigner))?
.map_err(|_| {
TransactionValidityError::Invalid(InvalidTransaction::BadSigner)
})?;
let tx = Tx::decode(&mut &tx_bytes[..])
.map_err(|_| TransactionValidityError::Invalid(InvalidTransaction::Call))?;
let fee_payer = T::SigVerifiableTx::fee_payer(&tx)
.map_err(|_| TransactionValidityError::Invalid(InvalidTransaction::Call))?;
let (_hrp, address_raw) = acc_address_from_bech32(&fee_payer).map_err(|_| {
TransactionValidityError::Invalid(InvalidTransaction::BadSigner)
})?;

if address_raw.len() != 20 {
return Err(TransactionValidityError::Invalid(InvalidTransaction::BadSigner));
Expand Down

0 comments on commit 55ad1ac

Please sign in to comment.