Set address book suggestions
This commit is contained in:
parent
6240afc07a
commit
6d2638410f
|
@ -50,7 +50,7 @@ const AddressBookInput = ({
|
||||||
}: any) => {
|
}: any) => {
|
||||||
const addressBook = useSelector(getAddressBookListSelector)
|
const addressBook = useSelector(getAddressBookListSelector)
|
||||||
const [isValidForm, setIsValidForm] = useState(true)
|
const [isValidForm, setIsValidForm] = useState(true)
|
||||||
const [validationText, setValidationText] = useState<any>(true)
|
const [validationText, setValidationText] = useState<any>('')
|
||||||
const [inputTouched, setInputTouched] = useState(false)
|
const [inputTouched, setInputTouched] = useState(false)
|
||||||
const [blurred, setBlurred] = useState(pristine)
|
const [blurred, setBlurred] = useState(pristine)
|
||||||
const [adbkList, setADBKList] = useState(List([]))
|
const [adbkList, setADBKList] = useState(List([]))
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import { makeStyles } from '@material-ui/core/styles'
|
import { makeStyles } from '@material-ui/core/styles'
|
||||||
import React from 'react'
|
import React, { useState } from 'react'
|
||||||
|
|
||||||
import { ScanQRWrapper } from 'src/components/ScanQRModal/ScanQRWrapper'
|
import { ScanQRWrapper } from 'src/components/ScanQRModal/ScanQRWrapper'
|
||||||
|
import AddressBookInput from 'src/routes/safe/components/Balances/SendModal/screens/AddressBookInput'
|
||||||
import Field from 'src/components/forms/Field'
|
import Field from 'src/components/forms/Field'
|
||||||
import TextField from 'src/components/forms/TextField'
|
import TextField from 'src/components/forms/TextField'
|
||||||
import {
|
import {
|
||||||
|
@ -22,12 +23,26 @@ export interface EthAddressProps {
|
||||||
name: string
|
name: string
|
||||||
onScannedValue: (scannedValue: string) => void
|
onScannedValue: (scannedValue: string) => void
|
||||||
text: string
|
text: string
|
||||||
|
value?: string
|
||||||
|
pristine: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const EthAddressInput = ({ isContract = true, isRequired = true, name, onScannedValue, text }: EthAddressProps) => {
|
const EthAddressInput = ({
|
||||||
|
isContract = true,
|
||||||
|
isRequired = true,
|
||||||
|
name,
|
||||||
|
onScannedValue,
|
||||||
|
text,
|
||||||
|
value,
|
||||||
|
pristine,
|
||||||
|
}: EthAddressProps) => {
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
const validatorsList = [isRequired && required, mustBeEthereumAddress, isContract && mustBeEthereumContractAddress]
|
const validatorsList = [isRequired && required, mustBeEthereumAddress, isContract && mustBeEthereumContractAddress]
|
||||||
const validate = composeValidators(...validatorsList.filter((_) => _))
|
const validate = composeValidators(...validatorsList.filter((_) => _))
|
||||||
|
const [selectedEntry, setSelectedEntry] = useState<{ address?: string; name?: string } | null>({
|
||||||
|
address: value,
|
||||||
|
name: '',
|
||||||
|
})
|
||||||
|
|
||||||
const handleScan = (value, closeQrModal) => {
|
const handleScan = (value, closeQrModal) => {
|
||||||
let scannedAddress = value
|
let scannedAddress = value
|
||||||
|
@ -44,15 +59,25 @@ const EthAddressInput = ({ isContract = true, isRequired = true, name, onScanned
|
||||||
<>
|
<>
|
||||||
<Row margin="md">
|
<Row margin="md">
|
||||||
<Col xs={11}>
|
<Col xs={11}>
|
||||||
<Field
|
{selectedEntry && selectedEntry.address ? (
|
||||||
component={TextField}
|
<Field
|
||||||
name={name}
|
component={TextField}
|
||||||
placeholder={text}
|
name={name}
|
||||||
testId={name}
|
placeholder={text}
|
||||||
text={text}
|
testId={name}
|
||||||
type="text"
|
text={text}
|
||||||
validate={validate}
|
type="text"
|
||||||
/>
|
validate={validate}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<AddressBookInput
|
||||||
|
setSelectedEntry={setSelectedEntry}
|
||||||
|
setIsValidAddress={() => {}}
|
||||||
|
fieldMutator={onScannedValue}
|
||||||
|
isCustomTx
|
||||||
|
pristine={pristine}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
<Col center="xs" className={classes} middle="xs" xs={1}>
|
<Col center="xs" className={classes} middle="xs" xs={1}>
|
||||||
<ScanQRWrapper handleScan={handleScan} />
|
<ScanQRWrapper handleScan={handleScan} />
|
||||||
|
|
|
@ -100,15 +100,16 @@ const ContractInteraction: React.FC<ContractInteractionProps> = ({
|
||||||
>
|
>
|
||||||
{(submitting, validating, rest, mutators) => {
|
{(submitting, validating, rest, mutators) => {
|
||||||
setCallResults = mutators.setCallResults
|
setCallResults = mutators.setCallResults
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Block className={classes.formContainer}>
|
<Block className={classes.formContainer}>
|
||||||
<SafeInfo />
|
<SafeInfo />
|
||||||
<FormDivisor />
|
<FormDivisor />
|
||||||
<EthAddressInput
|
<EthAddressInput
|
||||||
|
value={rest.values.contractAddress}
|
||||||
name="contractAddress"
|
name="contractAddress"
|
||||||
onScannedValue={mutators.setContractAddress}
|
onScannedValue={mutators.setContractAddress}
|
||||||
|
pristine={rest.pristine}
|
||||||
text="Contract Address*"
|
text="Contract Address*"
|
||||||
/>
|
/>
|
||||||
<ContractABI />
|
<ContractABI />
|
||||||
|
|
Loading…
Reference in New Issue