-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement FE of withdrawals #431
Draft
mohandast52
wants to merge
4
commits into
staging
Choose a base branch
from
mohan/withdrawal-feature
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e9f5fd6
refactor: simplify AddFundsSection by removing styled component and u…
mohandast52 fe9ef5b
feat: add WithdrawFunds component and integrate it into YourAgentWallet
mohandast52 e8919c9
feat: enhance WithdrawFunds component with address validation and loa…
mohandast52 04a364d
feat: improve WithdrawFunds component with loading messages and input…
mohandast52 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { Button, Flex, Input, message, Modal, Typography } from 'antd'; | ||
import { isAddress } from 'ethers/lib/utils'; | ||
import React, { useCallback, useState } from 'react'; | ||
|
||
import { delayInSeconds } from '@/utils/delay'; | ||
|
||
import { CustomAlert } from '../Alert'; | ||
|
||
const { Text } = Typography; | ||
|
||
export const WithdrawFunds = () => { | ||
const [isModalVisible, setIsModalVisible] = useState(false); | ||
const [amount, setAmount] = useState(''); | ||
const [isWithdrawalLoading, setIsWithdrawalLoading] = useState(false); | ||
|
||
const showModal = useCallback(() => { | ||
setIsModalVisible(true); | ||
}, []); | ||
|
||
const handleCancel = useCallback(() => { | ||
setIsModalVisible(false); | ||
setAmount(''); | ||
}, []); | ||
|
||
const handleProceed = useCallback(async () => { | ||
if (!amount) return; | ||
|
||
const isValidAddress = isAddress(amount); | ||
if (!isValidAddress) { | ||
message.error('Please enter a valid address'); | ||
return; | ||
} | ||
|
||
message.loading('Withdrawal pending. It may take a few minutes.'); | ||
|
||
setIsWithdrawalLoading(true); | ||
await delayInSeconds(2); // TODO: integrate with the backend | ||
setIsWithdrawalLoading(false); | ||
|
||
message.success('Transaction complete.'); | ||
}, [amount]); | ||
|
||
return ( | ||
<> | ||
<Button onClick={showModal} block style={{ fontSize: 14 }}> | ||
Withdraw all funds | ||
</Button> | ||
|
||
<Modal | ||
title="Withdraw Funds" | ||
open={isModalVisible} | ||
footer={null} | ||
onCancel={handleCancel} | ||
width={400} | ||
destroyOnClose | ||
> | ||
<Flex vertical gap={16} style={{ marginTop: 12 }}> | ||
<Text> | ||
To proceed, enter the EVM-compatible wallet address where you’d like | ||
to receive your funds. Funds will be sent on Gnosis Chain. | ||
</Text> | ||
|
||
<CustomAlert | ||
type="warning" | ||
showIcon | ||
message={ | ||
<Text className="text-sm"> | ||
Ensure you have access to this wallet to avoid losing assets. | ||
</Text> | ||
} | ||
/> | ||
|
||
<Input | ||
value={amount} | ||
onChange={(e) => setAmount(e.target.value)} | ||
placeholder="0x..." | ||
size="small" | ||
className="text-base" | ||
style={{ padding: '6px 12px' }} | ||
/> | ||
|
||
<Button | ||
disabled={!amount} | ||
loading={isWithdrawalLoading} | ||
onClick={handleProceed} | ||
block | ||
type="primary" | ||
className="text-base" | ||
> | ||
Proceed | ||
</Button> | ||
|
||
<Text className="text-sm text-light"> | ||
After withdrawal, you won’t be able to run your agent until you fund | ||
it with the required amounts again. Some funds may be locked in | ||
prediction markets and cannot be withdrawn at this time. | ||
</Text> | ||
</Flex> | ||
</Modal> | ||
</> | ||
); | ||
}; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-fetch everything, including balances, wallet details, etc., to ensure it’s up-to-date.