From a73f9c648b4b3638790bb41288f393dab48e0581 Mon Sep 17 00:00:00 2001 From: "refcell.eth" Date: Fri, 10 Mar 2023 11:05:34 -0500 Subject: [PATCH] fix: Optional CallOpts Recipient (#207) --- execution/src/evm.rs | 4 ++-- execution/src/rpc/http_rpc.rs | 2 +- execution/src/types.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/execution/src/evm.rs b/execution/src/evm.rs index 223b330..a0a349d 100644 --- a/execution/src/evm.rs +++ b/execution/src/evm.rs @@ -131,7 +131,7 @@ impl<'a, R: ExecutionRpc> Evm<'a, R> { }; let to_access_entry = AccessListItem { - address: opts_moved.to, + address: opts_moved.to.unwrap_or_default(), storage_keys: Vec::default(), }; @@ -172,7 +172,7 @@ impl<'a, R: ExecutionRpc> Evm<'a, R> { let mut env = Env::default(); let payload = &self.evm.db.as_ref().unwrap().current_payload; - env.tx.transact_to = TransactTo::Call(opts.to); + env.tx.transact_to = TransactTo::Call(opts.to.unwrap_or_default()); env.tx.caller = opts.from.unwrap_or(Address::zero()); env.tx.value = opts.value.unwrap_or(U256::from(0)); env.tx.data = Bytes::from(opts.data.clone().unwrap_or_default()); diff --git a/execution/src/rpc/http_rpc.rs b/execution/src/rpc/http_rpc.rs index cc48953..2007f3a 100644 --- a/execution/src/rpc/http_rpc.rs +++ b/execution/src/rpc/http_rpc.rs @@ -63,7 +63,7 @@ impl ExecutionRpc for HttpRpc { let block = Some(BlockId::from(block)); let mut raw_tx = Eip1559TransactionRequest::new(); - raw_tx.to = Some(opts.to.into()); + raw_tx.to = Some(opts.to.unwrap_or_default().into()); raw_tx.from = opts.from; raw_tx.value = opts.value; raw_tx.gas = Some(opts.gas.unwrap_or(U256::from(100_000_000))); diff --git a/execution/src/types.rs b/execution/src/types.rs index 16b7c63..eea31e4 100644 --- a/execution/src/types.rs +++ b/execution/src/types.rs @@ -64,7 +64,7 @@ pub enum Transactions { #[serde(rename_all = "camelCase")] pub struct CallOpts { pub from: Option
, - pub to: Address, + pub to: Option
, pub gas: Option, pub gas_price: Option, pub value: Option, @@ -90,7 +90,7 @@ where let bytes: Option = serde::Deserialize::deserialize(deserializer)?; match bytes { Some(bytes) => { - let bytes = hex::decode(bytes.strip_prefix("0x").unwrap()).unwrap(); + let bytes = hex::decode(bytes.strip_prefix("0x").unwrap_or("")).unwrap_or_default(); Ok(Some(bytes.to_vec())) } None => Ok(None),