feat: cargo project at root

This commit is contained in:
binarybaron 2024-08-08 00:49:04 +02:00
parent aa0c0623ca
commit 709a2820c4
No known key found for this signature in database
GPG key ID: 99B75D3E1476A26E
313 changed files with 1 additions and 740 deletions

View file

@ -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}
/>
);
}

View file

@ -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}
/>
);
}