Skip to content

Commit

Permalink
feat: accept otp in the withdrawal form and pass it down to send API
Browse files Browse the repository at this point in the history
  • Loading branch information
rushilbg committed Jul 18, 2024
1 parent 3d3426d commit b3f1b6d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
10 changes: 10 additions & 0 deletions src/containers/V1BtcSweep/V1BtcSweepForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const validationSchema = Yup.object({
unspents: Yup.mixed().required(),
destinationAddress: Yup.string().required(),
encryptedUserKey: Yup.string().required(),
otp: Yup.string().required(),
}).required();

export type V1BtcSweepFormProps = {
Expand All @@ -30,6 +31,7 @@ export function V1BtcSweepForm({onSubmit}: V1BtcSweepFormProps) {
unspents: undefined,
destinationAddress: '',
encryptedUserKey: '',
otp: '',
},
validationSchema,
});
Expand Down Expand Up @@ -82,6 +84,14 @@ export function V1BtcSweepForm({onSubmit}: V1BtcSweepFormProps) {
}}
/>
</div>
<div className="tw-mb-4">
<FormikTextfield
HelperText={`2FA`}
Label="2FA Code"
name="otp"
Width="fill"
/>
</div>

<div className="tw-flex tw-flex-col-reverse sm:tw-justify-between sm:tw-flex-row tw-gap-1 tw-mt-4">
<Button Tag={Link} to="/" Variant="secondary" Width="hug">
Expand Down
9 changes: 5 additions & 4 deletions src/containers/V1BtcSweep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export function V1BtcSweep() {
try {
const unspents = JSON.parse(event.target?.result as string) as BitGoV1Unspent[];
setSubmitting(true);
await window.commands.unlock(values.otp);
const chainData = await window.queries.getChain(coin);
const result = await window.commands.sweepV1(coin, {
walletId: values.walletId,
Expand Down Expand Up @@ -68,14 +69,14 @@ export function V1BtcSweep() {
`/${environment}/v1btc-sweep/${coin}/success`
);
} catch (error) {
setSubmitting(false);
console.log(error);
if (error instanceof Error) {
setFieldError('unspents', error.message);
setAlert(error.message);
} else {
console.log(error);
}
} finally {
setSubmitting(false);
}
setSubmitting(false);
};

}}
Expand Down

0 comments on commit b3f1b6d

Please sign in to comment.