Skip to content

Commit

Permalink
fix(ens): set the resolved ens addr for gas estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
gakonst committed Aug 30, 2021
1 parent 8fcf5e7 commit 1e5a9ef
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ethers-providers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,15 @@ pub trait Middleware: Sync + Send + Debug {
tx: &mut TypedTransaction,
block: Option<BlockId>,
) -> Result<(), Self::Error> {
let tx_clone = tx.clone();
let mut tx_clone = tx.clone();

// TODO: Maybe deduplicate the code in a nice way
match tx {
TypedTransaction::Legacy(ref mut inner) => {
if let Some(NameOrAddress::Name(ref ens_name)) = inner.to {
let addr = self.resolve_name(ens_name).await?;
inner.to = Some(addr.into());
tx_clone.set_to(addr);
};

if inner.from.is_none() {
Expand All @@ -244,6 +245,7 @@ pub trait Middleware: Sync + Send + Debug {
if let Some(NameOrAddress::Name(ref ens_name)) = inner.tx.to {
let addr = self.resolve_name(ens_name).await?;
inner.tx.to = Some(addr.into());
tx_clone.set_to(addr);
};

if inner.tx.from.is_none() {
Expand All @@ -265,6 +267,7 @@ pub trait Middleware: Sync + Send + Debug {
if let Some(NameOrAddress::Name(ref ens_name)) = inner.to {
let addr = self.resolve_name(ens_name).await?;
inner.to = Some(addr.into());
tx_clone.set_to(addr);
};

if inner.from.is_none() {
Expand Down

0 comments on commit 1e5a9ef

Please sign in to comment.