diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 6f6ab39..0000000 --- a/.eslintignore +++ /dev/null @@ -1,4 +0,0 @@ -# Auto Generated PWA files -public/sw* -public/workbox* -ipfs/* diff --git a/.eslintrc.js b/.eslintrc.js index d8b91ad..c90921c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -25,6 +25,7 @@ module.exports = { react: {version: 'detect'}, 'import/resolver': {typescript: {}} }, + ignorePatterns: ['public/sw*', 'public/workbox*', 'ipfs/*'], rules: { 'import/default': 0, 'react/prop-types': 0, diff --git a/.vscode/settings.json b/.vscode/settings.json index 2afec2b..5c79875 100755 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,7 +9,7 @@ "editor.wordWrap": "off", "editor.autoIndent": "keep", "editor.codeActionsOnSave": { - "source.fixAll": true + "source.fixAll": "explicit" }, "editor.quickSuggestions": { "strings": true diff --git a/bun.lockb b/bun.lockb index 9576dfa..08aed6a 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/components/common/AddressInput.tsx b/components/common/AddressInput.tsx deleted file mode 100644 index aa33765..0000000 --- a/components/common/AddressInput.tsx +++ /dev/null @@ -1,134 +0,0 @@ -import React, {useCallback, useMemo, useRef, useState} from 'react'; -import {checkENSValidity} from 'utils/tools.ens'; -import {checkLensValidity} from 'utils/tools.lens'; -import {IconCircleCheck} from '@icons/IconCircleCheck'; -import {IconCircleCross} from '@icons/IconCircleCross'; -import {IconLoader} from '@yearn-finance/web-lib/icons/IconLoader'; -import {isZeroAddress, toAddress} from '@yearn-finance/web-lib/utils/address'; -import {cl} from '@yearn-finance/web-lib/utils/cl'; -import {ZERO_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; - -import type {ReactElement} from 'react'; -import type {TAddress} from '@yearn-finance/web-lib/types'; - -export type TAddressInput = { - value: TInputAddressLike; - onChangeValue: (value: TInputAddressLike) => void; - inputClassName?: string; -}; -export type TInputAddressLike = { - address: TAddress | undefined; - label: string; - isValid: boolean | 'undetermined'; -}; -export const defaultInputAddressLike: TInputAddressLike = { - address: undefined, - label: '', - isValid: false -}; - -function AddressInput({value, onChangeValue, ...props}: TAddressInput): ReactElement { - const [isLoadingValidish, set_isLoadingValidish] = useState(false); - const currentLabel = useRef(value.label); - const isFocused = useRef(false); - const status = useMemo((): 'valid' | 'invalid' | 'warning' | 'pending' | 'none' => { - if (value.isValid === true) { - return 'valid'; - } - if (value.isValid === false && value.label !== '' && value.address === ZERO_ADDRESS) { - return 'invalid'; - } - if (value.isValid === false && value.label !== '' && !isLoadingValidish && !isFocused.current) { - return 'invalid'; - } - if (isLoadingValidish) { - return 'pending'; - } - return 'none'; - }, [value, isLoadingValidish, isFocused]); - - const onChange = useCallback( - async (label: string): Promise => { - currentLabel.current = label; - - if (label.endsWith('.eth') && label.length > 4) { - onChangeValue({address: undefined, label, isValid: 'undetermined'}); - set_isLoadingValidish(true); - const [address, isValid] = await checkENSValidity(label); - if (currentLabel.current === label) { - onChangeValue({address, label, isValid}); - } - set_isLoadingValidish(false); - } else if (label.endsWith('.lens') && label.length > 5) { - onChangeValue({address: undefined, label, isValid: 'undetermined'}); - set_isLoadingValidish(true); - const [address, isValid] = await checkLensValidity(label); - if (currentLabel.current === label) { - onChangeValue({address, label, isValid}); - } - set_isLoadingValidish(false); - } else if (!isZeroAddress(toAddress(label))) { - onChangeValue({address: toAddress(label), label, isValid: true}); - } else { - onChangeValue({address: undefined, label, isValid: false}); - } - }, - [onChangeValue, currentLabel] - ); - - return ( -
- => { - isFocused.current = true; - onChange(value.label); - }} - onBlur={(): void => { - isFocused.current = false; - }} - onChange={async (e): Promise => onChange(e.target.value)} - required - autoComplete={'off'} - spellCheck={false} - placeholder={'0x...'} - type={'text'} - value={value.label} - className={cl(props.inputClassName, 'smol--input font-mono font-bold')} - /> - -
- ); -} - -export default AddressInput; diff --git a/components/common/ComboboxAddressInput/PossibleOption.tsx b/components/common/ComboboxAddressInput/PossibleOption.tsx deleted file mode 100644 index 55c1869..0000000 --- a/components/common/ComboboxAddressInput/PossibleOption.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import React, {useMemo} from 'react'; -import {Combobox} from '@headlessui/react'; -import {IconCircleCheck} from '@icons/IconCircleCheck'; -import {toAddress} from '@yearn-finance/web-lib/utils/address'; -import {ImageWithFallback} from '@common/ImageWithFallback'; - -import type {ReactElement} from 'react'; -import type {TToken} from '@types'; - -function Option(props: TToken): ReactElement { - return ( -
-
- -
-
-
{props.symbol}
- {toAddress(props.address)} -
-
- ); -} - -function PossibleOption({option}: {option: TToken}): ReactElement { - const memorizedElement = useMemo((): ReactElement =>