-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1493ed6
commit e917902
Showing
14 changed files
with
256 additions
and
221 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'hostd': minor | ||
'renterd': minor | ||
'@siafoundation/design-system': minor | ||
--- | ||
|
||
The send siacoin feature now validates the address. |
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,5 @@ | ||
--- | ||
'@siafoundation/design-system': minor | ||
--- | ||
|
||
WalletSendSiacoinDialog no longer uses formik. |
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
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
61 changes: 34 additions & 27 deletions
61
libs/design-system/src/app/WalletSendSiacoinDialog/Confirm.tsx
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 |
---|---|---|
@@ -1,59 +1,66 @@ | ||
import { useFormik } from 'formik' | ||
import { useForm } from 'react-hook-form' | ||
import BigNumber from 'bignumber.js' | ||
import { WalletSendSiacoinReceipt } from './Receipt' | ||
import { SendSiacoinFormData } from './types' | ||
import { SendSiacoinParams } from './types' | ||
import { triggerErrorToast } from '../../lib/toast' | ||
import { useCallback, useMemo } from 'react' | ||
|
||
type Props = { | ||
send: ( | ||
params: SendSiacoinFormData | ||
params: SendSiacoinParams & { includeFee: boolean } | ||
) => Promise<{ transactionId?: string; error?: string }> | ||
formData: SendSiacoinFormData | ||
params: SendSiacoinParams | ||
fee: BigNumber | ||
onConfirm: (params: { transactionId?: string }) => void | ||
} | ||
|
||
export function useSendSiacoinConfirmForm({ | ||
send, | ||
formData, | ||
params, | ||
fee, | ||
onConfirm, | ||
}: Props) { | ||
const { address, hastings, includeFee } = formData || {} | ||
const formik = useFormik({ | ||
initialValues: {}, | ||
onSubmit: async () => { | ||
const { transactionId, error } = await send({ | ||
address, | ||
hastings, | ||
includeFee, | ||
}) | ||
const { address, hastings } = params || {} | ||
const form = useForm({ | ||
defaultValues: {}, | ||
}) | ||
|
||
if (error) { | ||
formik.setStatus({ | ||
error, | ||
}) | ||
return | ||
} | ||
const onValid = useCallback(async () => { | ||
const { transactionId, error } = await send({ | ||
address, | ||
hastings, | ||
includeFee: false, | ||
}) | ||
|
||
onConfirm({ | ||
transactionId, | ||
if (error) { | ||
triggerErrorToast({ | ||
title: 'Error sending siacoin', | ||
body: error, | ||
}) | ||
}, | ||
}) | ||
return | ||
} | ||
|
||
onConfirm({ | ||
transactionId, | ||
}) | ||
}, [onConfirm, address, hastings, send]) | ||
|
||
const submit = useMemo(() => form.handleSubmit(onValid), [form, onValid]) | ||
|
||
const form = ( | ||
const el = ( | ||
<div className="flex flex-col gap-4"> | ||
<WalletSendSiacoinReceipt | ||
address={address} | ||
hastings={hastings} | ||
fee={fee} | ||
includeFee={includeFee} | ||
/> | ||
</div> | ||
) | ||
|
||
return { | ||
el, | ||
form, | ||
formik, | ||
reset: form.reset, | ||
submit, | ||
} | ||
} |
Oops, something went wrong.