mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-12-18 01:54:29 -05:00
feat: cargo project at root
This commit is contained in:
parent
aa0c0623ca
commit
709a2820c4
313 changed files with 1 additions and 740 deletions
|
|
@ -0,0 +1,41 @@
|
|||
import { useEffect } from 'react';
|
||||
import { TextField } from '@material-ui/core';
|
||||
import { TextFieldProps } from '@material-ui/core/TextField/TextField';
|
||||
import { isBtcAddressValid } from 'utils/conversionUtils';
|
||||
import { isTestnet } from 'store/config';
|
||||
|
||||
export default function BitcoinAddressTextField({
|
||||
address,
|
||||
onAddressChange,
|
||||
onAddressValidityChange,
|
||||
helperText,
|
||||
...props
|
||||
}: {
|
||||
address: string;
|
||||
onAddressChange: (address: string) => void;
|
||||
onAddressValidityChange: (valid: boolean) => void;
|
||||
helperText: string;
|
||||
} & TextFieldProps) {
|
||||
const placeholder = isTestnet() ? 'tb1q4aelwalu...' : 'bc18ociqZ9mZ...';
|
||||
const errorText = isBtcAddressValid(address, isTestnet())
|
||||
? null
|
||||
: `Only bech32 addresses are supported. They begin with "${
|
||||
isTestnet() ? 'tb1' : 'bc1'
|
||||
}"`;
|
||||
|
||||
useEffect(() => {
|
||||
onAddressValidityChange(!errorText);
|
||||
}, [address, errorText, onAddressValidityChange]);
|
||||
|
||||
return (
|
||||
<TextField
|
||||
value={address}
|
||||
onChange={(e) => onAddressChange(e.target.value)}
|
||||
error={!!errorText && address.length > 0}
|
||||
helperText={address.length > 0 ? errorText || helperText : helperText}
|
||||
placeholder={placeholder}
|
||||
variant="outlined"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
import { useEffect } from 'react';
|
||||
import { TextField } from '@material-ui/core';
|
||||
import { TextFieldProps } from '@material-ui/core/TextField/TextField';
|
||||
import { isXmrAddressValid } from 'utils/conversionUtils';
|
||||
import { isTestnet } from 'store/config';
|
||||
|
||||
export default function MoneroAddressTextField({
|
||||
address,
|
||||
onAddressChange,
|
||||
onAddressValidityChange,
|
||||
helperText,
|
||||
...props
|
||||
}: {
|
||||
address: string;
|
||||
onAddressChange: (address: string) => void;
|
||||
onAddressValidityChange: (valid: boolean) => void;
|
||||
helperText: string;
|
||||
} & TextFieldProps) {
|
||||
const placeholder = isTestnet() ? '59McWTPGc745...' : '888tNkZrPN6J...';
|
||||
const errorText = isXmrAddressValid(address, isTestnet())
|
||||
? null
|
||||
: 'Not a valid Monero address';
|
||||
|
||||
useEffect(() => {
|
||||
onAddressValidityChange(!errorText);
|
||||
}, [address, onAddressValidityChange, errorText]);
|
||||
|
||||
return (
|
||||
<TextField
|
||||
value={address}
|
||||
onChange={(e) => onAddressChange(e.target.value)}
|
||||
error={!!errorText && address.length > 0}
|
||||
helperText={address.length > 0 ? errorText || helperText : helperText}
|
||||
placeholder={placeholder}
|
||||
variant="outlined"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue