Skip to content

Commit

Permalink
Fixed lookupAddress when bad resolver is present (#3782).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Feb 15, 2023
1 parent 557c7d4 commit 92def9c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
12 changes: 11 additions & 1 deletion src.ts/_tests/test-providers-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,21 @@ describe("Test Provider Transaction operations", function() {

// Cloudflare doesn't return the root in legacy receipts; but it isn't
// *actually* that important, so we'll give it a pass...
if (providerName === "CloudflareProvider") {
if (providerName === "CloudflareProvider" || providerName === "AnkrProvider" || providerName === "PocketProvider") {
test = Object.assign({ } , test, { root: undefined });
}

//if (providerName === "PocketProvider") {
//}

assertReceipt(receipt, test);
};
});

forEach("test lookupAddress(addr) == null", testReceipt, (providerName, test) => {
return async (provider) => {
const name = await provider.lookupAddress("0x0123456789012345678901234567890123456789")
assert.ok(name == null, "name == null");
};
});
});
17 changes: 12 additions & 5 deletions src.ts/providers/abstract-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Transaction } from "../transaction/index.js";
import {
concat, dataLength, dataSlice, hexlify, isHexString,
getBigInt, getBytes, getNumber,
isCallException, makeError, assert, assertArgument,
isCallException, isError, makeError, assert, assertArgument,
FetchRequest,
toBeArray, toQuantity,
defineProperties, EventPayload, resolveProperties,
Expand Down Expand Up @@ -988,14 +988,21 @@ export class AbstractProvider implements Provider {
], this);
const name = await resolverContract.name(node);

// Failed forward resolution
const check = await this.resolveName(name);
if (check !== address) {
console.log("FAIL", address, check);
}
if (check !== address) { return null; }

return name;
} catch (error) {
console.log("TEMP", error);
// No data was returned from the resolver
if (isError(error, "BAD_DATA") && error.value === "0x") {
return null;
}

// Something reerted
if (isError(error, "CALL_EXCEPTION")) { return null; }

throw error;
}

return null;
Expand Down

0 comments on commit 92def9c

Please sign in to comment.