Skip to content
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

Revert "DAO-686: Add checksum conversion (#225)" #260

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,3 @@ This can be removed in the future.
### End-to-end testing (e2e)

This workflow uses https://github.com/cypress-io/github-action

60 changes: 0 additions & 60 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-select": "^2.1.1",
"@radix-ui/react-slot": "^1.1.0",
"@rsksmart/rsk-utils": "^1.1.0",
"@tanstack/react-query": "^5.48.0",
"axios": "^1.7.4",
"class-variance-authority": "^0.7.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ FormDescription.displayName = 'FormDescription'
const FormMessage = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
({ className, children, ...props }, ref) => {
const { error, formMessageId } = useFormField()
const body = children || String(error?.message || '')
const body = error ? String(error?.message) : children

if (!body) {
return null
Expand Down
6 changes: 0 additions & 6 deletions src/index.d.ts

This file was deleted.

30 changes: 5 additions & 25 deletions src/pages/proposals/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ import { MAX_INPUT_NUMBER_AMOUNT } from '@/components/Input/InputNumber'
import { MainContainer } from '@/components/MainContainer/MainContainer'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/Select'
import { Header, Paragraph } from '@/components/Typography'
import { ENV } from '@/lib/constants'
import { tokenContracts } from '@/lib/contracts'
import { formatCurrency } from '@/lib/utils'
import { rbtcIconSrc } from '@/shared/rbtcIconSrc'
import { TX_MESSAGES } from '@/shared/txMessages'
import { zodResolver } from '@hookform/resolvers/zod'
import { isAddress, isValidChecksumAddress, toChecksumAddress } from '@rsksmart/rsk-utils'
import Image from 'next/image'
import { useRouter } from 'next/navigation'
import { useEffect, useMemo, useState } from 'react'
import { useForm } from 'react-hook-form'
import { GoRocket } from 'react-icons/go'
import { Address, zeroAddress } from 'viem'
import { z } from 'zod'
import { rbtcIconSrc } from '@/shared/rbtcIconSrc'
import { ENV } from '@/lib/constants'

const ADDRESS_REGEX = /^0x[a-fA-F0-9]{40}$/
const rifMinimumAmount = ENV === 'mainnet' ? 10 : 1
const rbtcMinimumAmount = ENV === 'mainnet' ? 0.0001 : 0.000001

Expand All @@ -49,10 +49,7 @@ const FormSchema = z
.string()
.max(3000)
.refine(s => s.trim().replace(/\s+/g, ' ').length >= 10, 'Field must contain at least 10 characters'),
toAddress: z
.string()
.refine(value => isAddress(value), 'Please enter a valid address')
.refine(value => isValidChecksumAddress(value) || value === value.toLowerCase(), 'Invalid checksum'),
toAddress: z.string().refine(value => ADDRESS_REGEX.test(value), 'Please enter a valid address'),
tokenAddress: z.string().length(42),
amount: z.coerce
.number({ invalid_type_error: 'Required field' })
Expand Down Expand Up @@ -95,7 +92,6 @@ export default function CreateProposal() {
formState: { touchedFields, errors, isValid, isDirty },
watch,
trigger,
setValue,
} = form

const pricesMap = useMemo(
Expand Down Expand Up @@ -237,23 +233,7 @@ export default function CreateProposal() {
<FormInput placeholder="0x123...456" {...field} data-testid="InputTransfer" />
</FormControl>
<FormDescription>Write or paste the wallet address of the recipient</FormDescription>
<FormMessage>
{errors.toAddress?.message === 'Invalid checksum' ? (
<>
Please check that the address is correct before continuing. If the address is
correct, use the button below to convert your address to a valid checksum address.{' '}
<span
className="text-white underline cursor-pointer"
onClick={() => {
setValue('toAddress', toChecksumAddress(field.value))
trigger('toAddress')
}}
>
Fix address.
</span>
</>
) : undefined}
</FormMessage>
<FormMessage />
</FormItem>
)}
/>
Expand Down