// Copyright 2017-2019 @polkadot/app-contracts authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. import { ApiProps } from '@polkadot/react-api/types'; import { I18nProps } from '@polkadot/react-components/types'; import { ActionStatus } from '@polkadot/react-components/Status/types'; import React from 'react'; import { withApi } from '@polkadot/react-api'; import { AddressRow, Button, Input } from '@polkadot/react-components'; import keyring from '@polkadot/ui-keyring'; import ContractModal, { ContractModalProps, ContractModalState } from '../Modal'; import ValidateAddr from './ValidateAddr'; import translate from '../translate'; interface Props extends ContractModalProps, ApiProps, I18nProps {} interface State extends ContractModalState { address?: string | null; isAddressValid: boolean; } class Add extends ContractModal { constructor (props: Props) { super(props); this.defaultState = { ...this.defaultState, address: null, name: 'New Contract', isAddressValid: false, isNameValid: true }; this.state = this.defaultState; this.headerText = props.t('Add an existing contract'); } public isContract = true; protected renderContent = (): React.ReactNode => { const { t } = this.props; const { address, isAddressValid, isBusy, name } = this.state; return ( {this.renderInputName()} {this.renderInputAbi()} ); } protected renderButtons = (): React.ReactNode => { const { t } = this.props; const { isAddressValid, isAbiValid, isNameValid } = this.state; const isValid = isNameValid && isAddressValid && isAbiValid; return ( {this.renderCancelButton()}