diff --git a/README.md b/README.md index ec0fbcbe..9e675089 100644 --- a/README.md +++ b/README.md @@ -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 - diff --git a/package-lock.json b/package-lock.json index 838ce94c..4091c9ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,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", @@ -7176,32 +7175,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@rsksmart/rsk-utils": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@rsksmart/rsk-utils/-/rsk-utils-1.1.0.tgz", - "integrity": "sha512-ZveRUj9AHGyxSPIwWIIKhjQ5XEWtaZa5HYt8zqEhv5HDSRW2KiaTffG/fGv07XwMtmLVo/DA5/a2Ak9igVaNSA==", - "license": "MIT", - "dependencies": { - "keccak": "^2.0.0", - "rlp": "^2.2.4" - } - }, - "node_modules/@rsksmart/rsk-utils/node_modules/keccak": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/keccak/-/keccak-2.1.0.tgz", - "integrity": "sha512-m1wbJRTo+gWbctZWay9i26v5fFnYkOn7D5PCxJ3fZUGUEb49dE1Pm4BREUYCt/aoO6di7jeoGmhvqN9Nzylm3Q==", - "hasInstallScript": true, - "license": "MIT", - "dependencies": { - "bindings": "^1.5.0", - "inherits": "^2.0.4", - "nan": "^2.14.0", - "safe-buffer": "^5.2.0" - }, - "engines": { - "node": ">=5.12.0" - } - }, "node_modules/@rushstack/eslint-patch": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.10.3.tgz", @@ -11865,15 +11838,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "license": "MIT", - "dependencies": { - "file-uri-to-path": "1.0.0" - } - }, "node_modules/bl": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", @@ -16121,12 +16085,6 @@ "node": ">=14.14" } }, - "node_modules/file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", - "license": "MIT" - }, "node_modules/filelist": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz", @@ -20634,12 +20592,6 @@ "thenify-all": "^1.0.0" } }, - "node_modules/nan": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.20.0.tgz", - "integrity": "sha512-bk3gXBZDGILuuo/6sKtr0DQmSThYHLtNCdSdXk9YkxD/jK6X2vmCyyXBBxyqZ4XcnzTyYEAThfX3DCEnLf6igw==", - "license": "MIT" - }, "node_modules/nanoid": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", @@ -23623,18 +23575,6 @@ "inherits": "^2.0.1" } }, - "node_modules/rlp": { - "version": "2.2.7", - "resolved": "https://registry.npmjs.org/rlp/-/rlp-2.2.7.tgz", - "integrity": "sha512-d5gdPmgQ0Z+AklL2NVXr/IoSjNZFfTVvQWzL/AM2AOcSzYP2xjlb0AC8YyCLc41MSNf6P6QVtjgPdmVtzb+4lQ==", - "license": "MPL-2.0", - "dependencies": { - "bn.js": "^5.2.0" - }, - "bin": { - "rlp": "bin/rlp" - } - }, "node_modules/rollup-plugin-visualizer": { "version": "5.12.0", "resolved": "https://registry.npmjs.org/rollup-plugin-visualizer/-/rollup-plugin-visualizer-5.12.0.tgz", diff --git a/package.json b/package.json index f2e89d0a..ae34d04c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/components/Form/Form.tsx b/src/components/Form/Form.tsx index f00d0472..72fe2dcd 100644 --- a/src/components/Form/Form.tsx +++ b/src/components/Form/Form.tsx @@ -130,7 +130,7 @@ FormDescription.displayName = 'FormDescription' const FormMessage = React.forwardRef>( ({ 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 diff --git a/src/index.d.ts b/src/index.d.ts deleted file mode 100644 index ed618cbc..00000000 --- a/src/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare module '@rsksmart/rsk-utils' { - export function toChecksumAddress(address: string, chainId?: number): string - export function isValidChecksumAddress(address: string, chainId?: number): boolean - export function isAddress(address: string): boolean -} -declare module '@rsksmart/rsk-contract-metadata' diff --git a/src/pages/proposals/create.tsx b/src/pages/proposals/create.tsx index 1b58f01b..08a8547d 100644 --- a/src/pages/proposals/create.tsx +++ b/src/pages/proposals/create.tsx @@ -21,13 +21,10 @@ 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' @@ -35,7 +32,10 @@ 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 @@ -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' }) @@ -95,7 +92,6 @@ export default function CreateProposal() { formState: { touchedFields, errors, isValid, isDirty }, watch, trigger, - setValue, } = form const pricesMap = useMemo( @@ -237,23 +233,7 @@ export default function CreateProposal() { Write or paste the wallet address of the recipient - - {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.{' '} - { - setValue('toAddress', toChecksumAddress(field.value)) - trigger('toAddress') - }} - > - Fix address. - - - ) : undefined} - + )} />