Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions clk-gateway/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,21 @@ app.get(
owner,
});
} catch (error) {
if (isParsableError(error)) {
const decodedError = CLICK_NAME_SERVICE_INTERFACE.parseError(
error.data,
);
if (decodedError !== null && typeof decodedError.name === "string") {
if (decodedError.name === "ERC721NonexistentToken") {
res.status(404).send({ error: "Name not found" });
return;
}
if (decodedError.name === "NameExpired") {
res.status(410).send({ error: "Name expired" });
return;
}
}
}
const errorMessage =
error instanceof Error ? error.message : String(error);
res.status(500).send({ error: errorMessage });
Expand Down
2 changes: 2 additions & 0 deletions clk-gateway/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export const CLICK_NAME_SERVICE_INTERFACE = new Interface([
"function expires(uint256 key) public view returns (uint256)",
"function register(address to, string memory name)",
"function resolve(string memory name) external view returns (address)",
"error NameExpired(address oldOwner, uint256 expiredAt)",
"error ERC721NonexistentToken(uint256 tokenId)",
]);

// The storage slot of ERC721._owners within the ClickNameService contract
Expand Down
Loading