-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this change adds support for arbitrum in WRW Ticket: WIN-1118
- Loading branch information
1 parent
190b993
commit c39cb95
Showing
9 changed files
with
964 additions
and
24 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
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
import { Form, FormikHelpers, FormikProvider, useFormik } from 'formik'; | ||
import { Link } from 'react-router-dom'; | ||
import * as Yup from 'yup'; | ||
import { Button, FormikTextfield } from '~/components'; | ||
|
||
const validationSchema = Yup.object({ | ||
apiKey: Yup.string().required(), | ||
backupKey: Yup.string().required(), | ||
backupKeyId: Yup.string(), | ||
gasLimit: Yup.number() | ||
.typeError('Gas limit must be a number') | ||
.integer() | ||
.positive('Gas limit must be a positive integer') | ||
.required(), | ||
gasPrice: Yup.number() | ||
.typeError('Gas price must be a number') | ||
.integer() | ||
.positive('Gas price must be a positive integer') | ||
.required(), | ||
recoveryDestination: Yup.string().required(), | ||
userKey: Yup.string().required(), | ||
userKeyId: Yup.string(), | ||
walletContractAddress: Yup.string().required(), | ||
}).required(); | ||
|
||
export type ArbitrumFormProps = { | ||
onSubmit: ( | ||
values: ArbitrumFormValues, | ||
formikHelpers: FormikHelpers<ArbitrumFormValues> | ||
) => void | Promise<void>; | ||
}; | ||
|
||
type ArbitrumFormValues = Yup.Asserts<typeof validationSchema>; | ||
|
||
export function ArbitrumForm({ onSubmit }: ArbitrumFormProps) { | ||
const formik = useFormik<ArbitrumFormValues>({ | ||
onSubmit, | ||
initialValues: { | ||
apiKey: '', | ||
backupKey: '', | ||
backupKeyId: '', | ||
gasLimit: 500000, | ||
gasPrice: 30, | ||
recoveryDestination: '', | ||
userKey: '', | ||
userKeyId: '', | ||
walletContractAddress: '', | ||
}, | ||
validationSchema, | ||
}); | ||
|
||
return ( | ||
<FormikProvider value={formik}> | ||
<Form> | ||
<h4 className="tw-text-body tw-font-semibold tw-border-b-0.5 tw-border-solid tw-border-gray-700 tw-mb-4"> | ||
Self-managed hot wallet details | ||
</h4> | ||
<div className="tw-mb-4"> | ||
<FormikTextfield | ||
HelperText="Your user public key, as found on your recovery KeyCard." | ||
Label="User Public Key" | ||
name="userKey" | ||
Width="fill" | ||
/> | ||
</div> | ||
<div className="tw-mb-4"> | ||
<FormikTextfield | ||
HelperText="Your user Key ID, as found on your KeyCard. Most wallets will not have this and you can leave it blank." | ||
Label="User Key ID (optional)" | ||
name="userKeyId" | ||
Width="fill" | ||
/> | ||
</div> | ||
<div className="tw-mb-4"> | ||
<FormikTextfield | ||
HelperText="The backup public key for the wallet, as found on your recovery KeyCard." | ||
Label="Backup Public Key" | ||
name="backupKey" | ||
Width="fill" | ||
/> | ||
</div> | ||
<div className="tw-mb-4"> | ||
<FormikTextfield | ||
HelperText="Your backup Key ID, as found on your KeyCard. Most wallets will not have this and you can leave it blank." | ||
Label="Backup Key ID (optional)" | ||
name="backupKeyId" | ||
Width="fill" | ||
/> | ||
</div> | ||
<div className="tw-mb-4"> | ||
<FormikTextfield | ||
HelperText="The Arbitrum address of the wallet contract. This is also the wallet's base address." | ||
Label="Wallet Contract Address" | ||
name="walletContractAddress" | ||
Width="fill" | ||
/> | ||
</div> | ||
<div className="tw-mb-4"> | ||
<FormikTextfield | ||
HelperText="The address your recovery transaction will send to." | ||
Label="Destination Address" | ||
name="recoveryDestination" | ||
Width="fill" | ||
/> | ||
</div> | ||
<div className="tw-mb-4"> | ||
<FormikTextfield | ||
HelperText="An API-Key Token from arbiscan.com required for Arbitrum mainnet recoveries." | ||
Label="API Key" | ||
name="apiKey" | ||
Width="fill" | ||
/> | ||
</div> | ||
<div className="tw-mb-4"> | ||
<FormikTextfield | ||
HelperText="Gas limit for the Arbitrum transaction. The value should be between 30,000 and 20,000,000. The default is 500,000 units of gas." | ||
Label="Gas limit" | ||
name="gasLimit" | ||
Width="fill" | ||
/> | ||
</div> | ||
<div className="tw-mb-4"> | ||
<FormikTextfield | ||
HelperText="Gas price for the Arbitrum transaction. The default is 30 Gwei." | ||
Label="Gas Price" | ||
name="gasPrice" | ||
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"> | ||
Cancel | ||
</Button> | ||
<Button | ||
Variant="primary" | ||
Width="hug" | ||
type="submit" | ||
Disabled={formik.isSubmitting} | ||
disabled={formik.isSubmitting} | ||
> | ||
{formik.isSubmitting ? 'Recovering...' : 'Recover Funds'} | ||
</Button> | ||
</div> | ||
</Form> | ||
</FormikProvider> | ||
); | ||
} |
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.