Skip to content

Commit 8f4993d

Browse files
committed
fix: validate the token address by querying a non-zero address due to OZ reverting on it
1 parent 635aa6d commit 8f4993d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

web/src/hooks/useTokenAddressValidation.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,12 @@ export const useERC20ERC721Validation = ({
7676
address,
7777
enabled = true,
7878
}: UseTokenValidationParams): TokenValidationResult => {
79+
// We query the balance for a random non-zero address because many implementations revert on it
7980
return useTokenValidation({
8081
address,
8182
enabled,
8283
abi: ERC20_ERC721_ABI,
83-
contractCall: (contract) => contract.read.balanceOf(["0x0000000000000000000000000000000000000000"]),
84+
contractCall: (contract) => contract.read.balanceOf(["0x0000000000000000000000000000000000001234"]),
8485
tokenType: "ERC-20 or ERC-721",
8586
});
8687
};
@@ -92,11 +93,12 @@ export const useERC20ERC721Validation = ({
9293
* @returns Validation state including loading, result, and error
9394
*/
9495
export const useERC1155Validation = ({ address, enabled = true }: UseTokenValidationParams): TokenValidationResult => {
96+
// We query the balance for a random non-zero address because many implementations revert on it
9597
return useTokenValidation({
9698
address,
9799
enabled,
98100
abi: ERC1155_ABI,
99-
contractCall: (contract) => contract.read.balanceOf(["0x0000000000000000000000000000000000000000", 0]),
101+
contractCall: (contract) => contract.read.balanceOf(["0x0000000000000000000000000000000000001234", 0]),
100102
tokenType: "ERC-1155",
101103
});
102104
};

0 commit comments

Comments
 (0)