Skip to content

Commit 3caad8b

Browse files
committed
Validate network supports ENS before resolution attempt
ENS resolution was attempted on any network including BSC and opBNB, where the ENS registry contract does not exist. This caused cryptic contract call errors instead of a clear message. - Added network allowlist check before ENS resolution - Supports Ethereum mainnet, Sepolia, and Goerli by name or chain ID - Returns clear error message when ENS is used on unsupported networks
1 parent c208ef9 commit 3caad8b

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/evm/services/ens.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ export async function resolveAddress(
2020

2121
// If it looks like an ENS name (contains a dot), try to resolve it
2222
if (addressOrEns.includes(".")) {
23+
const ensNetworks = ['ethereum', 'sepolia', 'goerli', '1', '11155111', '5'];
24+
if (!ensNetworks.includes(String(network).toLowerCase())) {
25+
throw new Error(`ENS resolution is only supported on Ethereum networks. Current: ${network}`);
26+
}
27+
2328
try {
2429
// Normalize the ENS name first
2530
const normalizedEns = normalize(addressOrEns)

0 commit comments

Comments
 (0)