add general types to ContractInteraction components
This commit is contained in:
parent
2c0bcfefe6
commit
7dfa7af41d
|
@ -9,7 +9,11 @@ import { isReadMethod } from 'src/routes/safe/components/Balances/SendModal/scre
|
|||
|
||||
const useStyles = makeStyles(styles)
|
||||
|
||||
const Buttons = ({ onClose }) => {
|
||||
export interface ButtonProps {
|
||||
onClose: () => void
|
||||
}
|
||||
|
||||
const Buttons = ({ onClose }: ButtonProps) => {
|
||||
const classes = useStyles()
|
||||
const {
|
||||
input: { value: method },
|
||||
|
|
|
@ -7,7 +7,7 @@ import { extractUsefulMethods } from 'src/logic/contractInteraction/sources/ABIS
|
|||
|
||||
export const NO_DATA = 'no data'
|
||||
|
||||
const mustBeValidABI = (abi) => {
|
||||
const mustBeValidABI = (abi: string): undefined | string => {
|
||||
try {
|
||||
const parsedABI = extractUsefulMethods(JSON.parse(abi))
|
||||
|
||||
|
@ -15,7 +15,7 @@ const mustBeValidABI = (abi) => {
|
|||
return NO_DATA
|
||||
}
|
||||
} catch (e) {
|
||||
return []
|
||||
return NO_DATA
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,15 @@ import { styles } from 'src/routes/safe/components/Balances/SendModal/screens/Co
|
|||
|
||||
const useStyles = makeStyles(styles)
|
||||
|
||||
const EthAddressInput = ({ isContract = true, isRequired = true, name, onScannedValue, text }) => {
|
||||
export interface EthAddressProps {
|
||||
isContract?: boolean
|
||||
isRequired?: boolean
|
||||
name: string
|
||||
onScannedValue: (scannedValue: string) => void
|
||||
text: string
|
||||
}
|
||||
|
||||
const EthAddressInput = ({ isContract = true, isRequired = true, name, onScannedValue, text }: EthAddressProps) => {
|
||||
const classes = useStyles()
|
||||
const validatorsList = [isRequired && required, mustBeEthereumAddress, isContract && mustBeEthereumContractAddress]
|
||||
const validate = composeValidators(...validatorsList.filter((_) => _))
|
||||
|
|
|
@ -17,7 +17,10 @@ import { safeSelector } from 'src/routes/safe/store/selectors'
|
|||
|
||||
const useStyles = makeStyles(styles)
|
||||
|
||||
const EthValue = ({ onSetMax }) => {
|
||||
interface EthValueProps {
|
||||
onSetMax: (ethBalance: string) => void
|
||||
}
|
||||
const EthValue = ({ onSetMax }: EthValueProps) => {
|
||||
const classes = useStyles()
|
||||
const { ethBalance } = useSelector(safeSelector)
|
||||
const {
|
||||
|
|
|
@ -9,7 +9,13 @@ import { styles } from 'src/routes/safe/components/Balances/SendModal/screens/Co
|
|||
|
||||
const useStyles = makeStyles(styles)
|
||||
|
||||
const Header = ({ onClose, subTitle, title }) => {
|
||||
interface HeaderProps {
|
||||
onClose: () => void
|
||||
subTitle: string
|
||||
title: string
|
||||
}
|
||||
|
||||
const Header = ({ onClose, subTitle, title }: HeaderProps) => {
|
||||
const classes = useStyles()
|
||||
|
||||
return (
|
||||
|
|
|
@ -19,7 +19,11 @@ import { extractUsefulMethods } from 'src/logic/contractInteraction/sources/ABIS
|
|||
|
||||
const MENU_WIDTH = '452px'
|
||||
|
||||
const MethodsDropdown = ({ onChange }) => {
|
||||
interface MethodsDropdownProps {
|
||||
onChange: ({}) => void
|
||||
}
|
||||
|
||||
const MethodsDropdown = ({ onChange }: MethodsDropdownProps) => {
|
||||
const classes = useDropdownStyles({ buttonWidth: MENU_WIDTH })
|
||||
const {
|
||||
input: { value: abi },
|
||||
|
|
|
@ -22,7 +22,21 @@ import { abiExtractor, createTxObject, formMutators, handleSubmitError, isReadMe
|
|||
|
||||
const useStyles = makeStyles(styles)
|
||||
|
||||
const ContractInteraction = ({ contractAddress, initialValues, onClose, onNext }) => {
|
||||
export interface CreatedTx {
|
||||
contractAddress: string
|
||||
data: string
|
||||
selectedMethod: {}
|
||||
value: string | number
|
||||
}
|
||||
|
||||
export interface ContractInteractionProps {
|
||||
contractAddress: string
|
||||
initialValues: { contractAddress?: string }
|
||||
onClose: () => void
|
||||
onNext: ({}: CreatedTx) => void
|
||||
}
|
||||
|
||||
const ContractInteraction = ({ contractAddress, initialValues, onClose, onNext }: ContractInteractionProps) => {
|
||||
const classes = useStyles()
|
||||
const { address: safeAddress = '' } = useSelector(safeSelector)
|
||||
let setCallResults
|
||||
|
|
Loading…
Reference in New Issue