forked from DimensionDev/Maskbook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: infinite approve amount (DimensionDev#4435)
- Loading branch information
1 parent
629c554
commit 620839c
Showing
3 changed files
with
22 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/web3-shared/src/hooks/useERC20TokenTotalSupply.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { useAsyncRetry } from 'react-use' | ||
import { EthereumAddress } from 'wallet.ts' | ||
import { useChainId } from '.' | ||
import { useERC20TokenContract } from '..' | ||
|
||
export function useERC20TokenTotalSupply(address?: string) { | ||
const chainId = useChainId() | ||
const erc20TokenContract = useERC20TokenContract(address) | ||
return useAsyncRetry(async () => { | ||
if (!address) return | ||
if (!EthereumAddress.isValid(address)) return | ||
return erc20TokenContract?.methods.totalSupply().call() | ||
}, [chainId, address, erc20TokenContract]) | ||
} |