From 7afde0ca0a6530dadecde0da3583784ea841b756 Mon Sep 17 00:00:00 2001 From: joshieDo <93316087+joshieDo@users.noreply.github.com> Date: Thu, 24 Feb 2022 18:42:32 +0200 Subject: [PATCH] handle case where the data from the resolver is empty (#963) * handle case where the data from the resolver is empty * is_empty instead of 0 comparison --- ethers-providers/src/provider.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ethers-providers/src/provider.rs b/ethers-providers/src/provider.rs index 02285a00..d2ddf209 100644 --- a/ethers-providers/src/provider.rs +++ b/ethers-providers/src/provider.rs @@ -1139,6 +1139,11 @@ impl Provider

{ // the call will return a Bytes array which we convert to an address let data = self.call(&ens::get_resolver(ens_addr, ens_name).into(), None).await?; + // otherwise, decode_bytes panics + if data.0.is_empty() { + return Err(ProviderError::EnsError(ens_name.to_owned())) + } + let resolver_address: Address = decode_bytes(ParamType::Address, data); if resolver_address == Address::zero() { return Err(ProviderError::EnsError(ens_name.to_owned()))