Skip to content

Commit

Permalink
better error message for contract query
Browse files Browse the repository at this point in the history
  • Loading branch information
mdtanrikulu committed May 8, 2024
1 parent 212be26 commit 3b8d725
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/service/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,22 @@ async function checkV1Contract(
);
assert(isInterfaceSupported);
return { tokenId: _tokenId, version: Version.v1w };
} catch (error) {
console.warn(`checkV1Contract: nft ownership check fails for ${_tokenId}`);
} catch (error: any) {
if (
// ethers error: given address is not contract, or does not have the supportsInterface method available
error?.info?.method === 'supportsInterface' ||
// assert error: given address is a contract but given INAMEWRAPPER interface is not available
(typeof error?.actual === 'boolean' && !error?.actual)
) {
// fail is expected for regular owners since the owner is not a contract and do not have supportsInterface method
console.warn(
`checkV1Contract: supportsInterface check fails for ${_tokenId}`
);
} else {
console.warn(
`checkV1Contract: nft ownership check fails for ${_tokenId}`
);
}
}
return { tokenId: _tokenId, version: Version.v1 };
}
Expand Down

0 comments on commit 3b8d725

Please sign in to comment.