Fixed lookupAddress when bad resolver is present (#3782).

This commit is contained in:
Richard Moore 2023-02-15 15:50:13 -05:00
parent 557c7d4224
commit 92def9c148
2 changed files with 23 additions and 6 deletions

@ -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");
};
});
});

@ -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,
@ -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;