Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/components/Common/EnhancedInputs.js
import * as React from 'react'; | import * as React from 'react'; | ||||
import PropTypes from 'prop-types'; | import PropTypes from 'prop-types'; | ||||
import { Form, Input, Select } from 'antd'; | import { Form, Input, Select } from 'antd'; | ||||
import { | import { | ||||
ThemedDollarOutlined, | ThemedDollarOutlined, | ||||
ThemedWalletOutlined, | ThemedWalletOutlined, | ||||
} from 'components/Common/CustomIcons'; | } from 'components/Common/CustomIcons'; | ||||
import styled, { css } from 'styled-components'; | import styled, { css } from 'styled-components'; | ||||
import ScanQRCode from './ScanQRCode'; | import ScanQRCode from './ScanQRCode'; | ||||
import useBCH from 'hooks/useBCH'; | |||||
import { currency } from 'components/Common/Ticker.js'; | import { currency } from 'components/Common/Ticker.js'; | ||||
const { TextArea } = Input; | const { TextArea } = Input; | ||||
export const AntdFormCss = css` | export const AntdFormCss = css` | ||||
input[type='number'] { | input[type='number'] { | ||||
-moz-appearance: textfield; | -moz-appearance: textfield; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 384 Lines • ▼ Show 20 Lines | return ( | ||||
width: '100%', | width: '100%', | ||||
}} | }} | ||||
{...selectProps} | {...selectProps} | ||||
> | > | ||||
{currencyOptions} | {currencyOptions} | ||||
</Select> | </Select> | ||||
); | ); | ||||
}; | }; | ||||
export const AddressValidators = () => { | |||||
const { BCH } = useBCH(); | |||||
return { | |||||
safelyDetectAddressFormat: value => { | |||||
try { | |||||
return BCH.Address.detectAddressFormat(value); | |||||
} catch (error) { | |||||
return null; | |||||
} | |||||
}, | |||||
isSLPAddress: value => | |||||
AddressValidators.safelyDetectAddressFormat(value) === 'slpaddr', | |||||
isBCHAddress: value => | |||||
AddressValidators.safelyDetectAddressFormat(value) === 'cashaddr', | |||||
isLegacyAddress: value => | |||||
AddressValidators.safelyDetectAddressFormat(value) === 'legacy', | |||||
}(); | |||||
}; |