Skip to content

Commit

Permalink
[DT-902] fix: Added final validation for Ens.reverseOf()
Browse files Browse the repository at this point in the history
  • Loading branch information
DChan0319 committed Sep 26, 2023
1 parent faa6b80 commit dc20f93
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Ens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export default class Ens extends NamingService {
// Current implementation uses reverseRegistrarContract to fetch the correct node hash.
// @see: https://eips.ethereum.org/EIPS/eip-181
async reverseOf(address: string): Promise<string | null> {
const originalAddress = address;
if (address.startsWith('0x')) {
address = address.substr(2);
}
Expand Down Expand Up @@ -225,7 +226,16 @@ export default class Ens extends NamingService {
this.proxyServiceApiKey,
);

return await this.resolverCallToName(resolverContract, nodeHash);
const domainName = await this.resolverCallToName(
resolverContract,
nodeHash,
);
const fetchedAddress = await this.addr(domainName, BlockchainType.ETH);
if (fetchedAddress?.toLowerCase() !== originalAddress.toLowerCase()) {
return null;
}

return domainName;
}

async getTokenUri(domain: string): Promise<string> {
Expand Down

0 comments on commit dc20f93

Please sign in to comment.