-
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.
Merge pull request #6 from SunDr17/web3
Create web3 withdraw functionality
- Loading branch information
Showing
9 changed files
with
89 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { | ||
type BaseError, | ||
useSendTransaction, | ||
} from 'wagmi'; | ||
import { parseEther } from 'viem'; | ||
import Button from 'react-bootstrap/Button'; | ||
|
||
export default function WithdrawButton({ withdrawSum }: { withdrawSum: number }) { | ||
const { t } = useTranslation(); | ||
const { | ||
error, | ||
isPending, | ||
sendTransaction, | ||
} = useSendTransaction(); | ||
|
||
async function withdraw() { | ||
sendTransaction({ | ||
to: process.env.REACT_APP_WEB3_WALLET_BASE_ADDRESS as `0x${string}`, | ||
value: parseEther(String(withdrawSum)), | ||
}); | ||
} | ||
|
||
return ( | ||
<> | ||
<Button className="mb-3" variant="primary" disabled={isPending} onClick={withdraw}> | ||
{t(`ref_program.referral_balance.withdraw_button.${isPending ? 'confirming' : 'withdraw'}`)} | ||
</Button> | ||
{error && ( | ||
<div className="text-danger"> | ||
{t( | ||
'ref_program.referral_balance.withdraw_button.error.label', | ||
{ error: t(`web3.error.${(error as BaseError).shortMessage || error.message}`) }, | ||
)} | ||
</div> | ||
)} | ||
</> | ||
); | ||
} |
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
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