Skip to content

Commit

Permalink
fix(platforms): added old ENS public resolver to list of legit public…
Browse files Browse the repository at this point in the history
… resolvers (#1882)
  • Loading branch information
lucianHymer authored Nov 9, 2023
1 parent 3f16d23 commit 8452ed6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
7 changes: 5 additions & 2 deletions platforms/src/Ens/Providers/EnsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import type { RequestPayload, VerifiedPayload } from "@gitcoin/passport-types";
// ----- Credential verification
import { getRPCProvider } from "../../utils/signer";

const ENS_PUBLIC_RESOLVER = "0x231b0ee14048e9dccd1d247744d114a4eb5e8e63";
const ENS_PUBLIC_RESOLVERS = [
"0x231b0ee14048e9dccd1d247744d114a4eb5e8e63",
"0x4976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41",
];

// Export a Ens Provider to carry out Ens name check and return a record object
export class EnsProvider implements Provider {
Expand All @@ -32,7 +35,7 @@ export class EnsProvider implements Provider {

if (reportedName) {
const resolver = await provider.getResolver(reportedName);
if (resolver?.address?.toLowerCase() === ENS_PUBLIC_RESOLVER) {
if (ENS_PUBLIC_RESOLVERS.includes(resolver?.address?.toLowerCase())) {
valid = true;
record = {
ens: reportedName,
Expand Down
24 changes: 24 additions & 0 deletions platforms/src/Ens/__tests__/EnsProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,30 @@ describe("Attempt verification", function () {
});
});

it("should return true for old public resolver", async () => {
EthersGetResolverMock.mockImplementation(async (_) => {
return Promise.resolve({
address: "0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41",
} as Resolver);
});

const ens = new EnsProvider();

const verifiedPayload = await ens.verify({
address: MOCK_ADDRESS,
} as unknown as RequestPayload);

expect(EthersLookupAddressMock).toBeCalledWith(MOCK_ADDRESS);

expect(verifiedPayload).toEqual({
valid: true,
record: {
ens: MOCK_ENS,
},
errors: [],
});
});

it("should return false for invalid address", async () => {
EthersLookupAddressMock.mockRejectedValueOnce("Invalid Address");
const ens = new EnsProvider();
Expand Down

0 comments on commit 8452ed6

Please sign in to comment.