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
This commit is contained in:
joshieDo 2022-02-24 18:42:32 +02:00 committed by GitHub
parent f1eaee52ef
commit 7afde0ca0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -1139,6 +1139,11 @@ impl<P: JsonRpcClient> Provider<P> {
// 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()))