Skip to content

Commit

Permalink
feat: add handleWrongNetwork for smart contract staff page
Browse files Browse the repository at this point in the history
  • Loading branch information
bigint committed Mar 1, 2024
1 parent 0bfe995 commit 2b91d50
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apps/web/src/components/Staff/SignupContract/Balance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import { Button, Spinner } from '@hey/ui';
import errorToast from '@lib/errorToast';
import { Leafwatch } from '@lib/leafwatch';
import { type FC, useState } from 'react';
import useHandleWrongNetwork from 'src/hooks/useHandleWrongNetwork';
import { formatUnits } from 'viem';
import { useBalance, useWriteContract } from 'wagmi';

import NumberedStat from '../UI/NumberedStat';

const Balance: FC = () => {
const [loading, setLoading] = useState(false);
const handleWrongNetwork = useHandleWrongNetwork();

const { data } = useBalance({
address: HEY_LENS_SIGNUP,
Expand All @@ -32,6 +34,7 @@ const Balance: FC = () => {
const withdraw = async () => {
try {
setLoading(true);
await handleWrongNetwork();

return await writeContractAsync({
abi: HeyLensSignup,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Button } from '@hey/ui';
import errorToast from '@lib/errorToast';
import { Leafwatch } from '@lib/leafwatch';
import { type FC, useState } from 'react';
import useHandleWrongNetwork from 'src/hooks/useHandleWrongNetwork';
import { formatUnits, parseEther } from 'viem';
import { useBalance, useReadContract, useSendTransaction } from 'wagmi';

Expand All @@ -20,6 +21,7 @@ interface RelayerBalanceProps {

const RelayerBalance: FC<RelayerBalanceProps> = ({ address, index }) => {
const [loading, setLoading] = useState(false);
const handleWrongNetwork = useHandleWrongNetwork();

const { data } = useBalance({
address: address,
Expand Down Expand Up @@ -50,6 +52,7 @@ const RelayerBalance: FC<RelayerBalanceProps> = ({ address, index }) => {
const refill = async () => {
try {
setLoading(true);
await handleWrongNetwork();

// Refill balance to 10 MATIC
return await sendTransactionAsync({
Expand Down

1 comment on commit 2b91d50

@vercel
Copy link

@vercel vercel bot commented on 2b91d50 Mar 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

web – ./apps/web

web-heyxyz.vercel.app
hey.xyz
web-git-main-heyxyz.vercel.app
heyxyz.vercel.app

Please sign in to comment.