File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -125,6 +125,21 @@ app.get(
125125 owner,
126126 } ) ;
127127 } catch ( error ) {
128+ if ( isParsableError ( error ) ) {
129+ const decodedError = CLICK_NAME_SERVICE_INTERFACE . parseError (
130+ error . data ,
131+ ) ;
132+ if ( decodedError !== null && typeof decodedError . name === "string" ) {
133+ if ( decodedError . name === "ERC721NonexistentToken" ) {
134+ res . status ( 404 ) . send ( { error : "Name not found" } ) ;
135+ return ;
136+ }
137+ if ( decodedError . name === "NameExpired" ) {
138+ res . status ( 410 ) . send ( { error : "Name expired" } ) ;
139+ return ;
140+ }
141+ }
142+ }
128143 const errorMessage =
129144 error instanceof Error ? error . message : String ( error ) ;
130145 res . status ( 500 ) . send ( { error : errorMessage } ) ;
Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ export const CLICK_NAME_SERVICE_INTERFACE = new Interface([
4444 "function expires(uint256 key) public view returns (uint256)" ,
4545 "function register(address to, string memory name)" ,
4646 "function resolve(string memory name) external view returns (address)" ,
47+ "error NameExpired(address oldOwner, uint256 expiredAt)" ,
48+ "error ERC721NonexistentToken(uint256 tokenId)" ,
4749] ) ;
4850
4951// The storage slot of ERC721._owners within the ClickNameService contract
You can’t perform that action at this time.
0 commit comments