// 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 React from 'react'; import { createType } from '@polkadot/types'; import { Button, Input } from '@polkadot/ui-app'; import ContractModal, { ContractModalProps, ContractModalState } from '../Modal'; import ValidateCode from './ValidateCode'; import store from '../store'; import translate from '../translate'; type Props = ContractModalProps; interface State extends ContractModalState { codeHash: string; isBusy: boolean; isCodeValid: boolean; } class Add extends ContractModal { public constructor (props: Props) { super(props); this.defaultState = { ...this.defaultState, codeHash: '', isBusy: false, isCodeValid: false }; this.state = this.defaultState; this.headerText = props.t('Add an existing code hash'); } protected renderContent = (): React.ReactNode => { const { t } = this.props; const { codeHash, isBusy, isCodeValid } = this.state; return ( <> {this.renderInputName()} {this.renderInputAbi()} ); } protected renderButtons = (): React.ReactNode => { const { t } = this.props; const { isBusy, isCodeValid, isNameValid } = this.state; const isValid = !isBusy && isCodeValid && isNameValid; return ( {this.renderCancelButton()}