Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch non-existing DNSSEC names #82

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions shared/src/core/universal_resolver/mod.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
use std::vec;

use ethers::prelude::ProviderError::JsonRpcClientError;
use ethers::{
providers::namehash,
types::{transaction::eip2718::TypedTransaction, Address, Bytes},
types::{Address, Bytes, transaction::eip2718::TypedTransaction},
};
use ethers::prelude::ProviderError::JsonRpcClientError;
use ethers_ccip_read::{CCIPReadMiddlewareError, CCIPRequest};
use ethers_core::abi;
use ethers_core::abi::{ParamType, Token};
use ethers_core::types::H160;
use hex_literal::hex;
use lazy_static::lazy_static;

use crate::core::error::ProfileError;
use crate::core::CCIPProvider;
use crate::models::lookup::{addr, ENSLookup};
use crate::core::error::ProfileError;
use crate::models::lookup::ENSLookup;
use crate::utils::dns::dns_encode;
use crate::utils::vec::dedup_ord;

Expand All @@ -23,6 +23,7 @@ lazy_static! {
Address::from(hex!("F142B308cF687d4358410a4cB885513b30A42025"));
}

#[derive(Debug, Clone)]
pub struct UniversalResolverResult {
pub(crate) success: bool,
pub(crate) data: Vec<u8>,
Expand Down Expand Up @@ -134,14 +135,11 @@ pub async fn resolve_universal(
})
.collect();

let addr = addr::decode(&parsed.remove(0).data).await;
let addr = parsed.remove(0);

// if we got a CCIP response, where the resolver is an OffchainDNSResolver and the address if zero
// it's a non-existing name
if resolver.is_zero()
|| (resolver == *OFFCHAIN_DNS_RESOLVER
&& matches!(addr, Ok(ref addr) if addr == "0x0000000000000000000000000000000000000000"))
{
// if we got a CCIP response, where the resolver is an OffchainDNSResolver and
// the address has failed to resolve, it's a non-existing name
if resolver.is_zero() || (resolver == *OFFCHAIN_DNS_RESOLVER && !addr.success) {
return Err(ProfileError::NotFound);
}

Expand Down Expand Up @@ -267,7 +265,7 @@ mod tests {
"Antony1060",
"AntonyThe1060",
"Antony1060",
"Croatia"
"Croatia",
]
);
}
Expand Down
Loading