From 59c88232635869031e477d1ed4a64f2f1ee200b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Wed, 14 Feb 2024 11:20:46 +0200 Subject: [PATCH] Decode EthTransaction: decode if no function call --- common/transaction/src/lib.rs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/common/transaction/src/lib.rs b/common/transaction/src/lib.rs index fa45ce32..fcd9de72 100644 --- a/common/transaction/src/lib.rs +++ b/common/transaction/src/lib.rs @@ -77,17 +77,26 @@ impl TopDecode for EthTransaction { let token_id = TokenIdentifier::dep_decode_or_handle_err(&mut nested_buffer, h)?; let amount = BigUint::dep_decode_or_handle_err(&mut nested_buffer, h)?; let tx_nonce = TxNonce::dep_decode_or_handle_err(&mut nested_buffer, h)?; - let data = ManagedBuffer::dep_decode_or_handle_err(&mut nested_buffer, h)?; - let gas_limit = u64::dep_decode_or_handle_err(&mut nested_buffer, h)?; + + let mut data = ManagedBuffer::new(); + let mut gas_limit = 0u64; let mut args = ManagedVec::new(); - while !nested_buffer.is_depleted() { - args.push(ManagedBuffer::dep_decode_or_handle_err( - &mut nested_buffer, - h, - )?); + if !nested_buffer.is_depleted() { + data = ManagedBuffer::dep_decode_or_handle_err(&mut nested_buffer, h)?; + gas_limit = u64::dep_decode_or_handle_err(&mut nested_buffer, h)?; + args = ManagedVec::new(); + + while !nested_buffer.is_depleted() { + args.push(ManagedBuffer::dep_decode_or_handle_err( + &mut nested_buffer, + h, + )?); + } + } + Result::Ok(EthTransaction { from, to,