Skip to content

Commit

Permalink
Merge pull request #103 from oceanprotocol/fix/not-enough-matic
Browse files Browse the repository at this point in the history
Fixing wrong error message shown
  • Loading branch information
jamiehewitt15 authored Oct 24, 2023
2 parents 6854521 + e59e6bc commit ac57f28
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/components/WrapMatic/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function WrapMatic(props: WrapMaticProps) {
const { chain } = useNetwork()
const { address } = useAccount()

const { data: balanceWallet } = useBalance({
const { data: balanceWallet, isSuccess: balanceSuccess } = useBalance({
address: address
})

Expand Down Expand Up @@ -62,7 +62,17 @@ export default function WrapMatic(props: WrapMaticProps) {
}, [isSuccess])

useEffect(() => {
if (!balanceWallet?.value || balanceWallet.value < props.amount) {
if (
balanceSuccess &&
balanceWallet?.value &&
balanceWallet?.value > props.amount
) {
setError(false)
setErrorMessage('')
} else if (
balanceSuccess &&
(!balanceWallet?.value || balanceWallet.value < props.amount)
) {
setError(true)
setErrorMessage('Not enough matic!')
} else if (wmaticIsError) {
Expand Down

0 comments on commit ac57f28

Please sign in to comment.