// 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 { I18nProps } from '@polkadot/react-components/types'; import BN from 'bn.js'; import React from 'react'; import { Abi } from '@polkadot/api-contract'; import { Button, Input, InputAddress, InputNumber, Modal, TxComponent } from '@polkadot/react-components'; import ABI from './ABI'; export interface ContractModalProps extends I18nProps { basePath: string; isNew?: boolean; isOpen: boolean; onClose?: () => void; } export interface ContractModalState { abi?: string | null; accountId?: string | null; contractAbi?: Abi | null; gasLimit: BN; isAbiSupplied: boolean; isAbiValid: boolean; isBusy: boolean; isNameValid: boolean; name?: string | null; tags: string[]; } class ContractModal

extends TxComponent { // horrible :( protected defaultState: S = { accountId: null, gasLimit: new BN(0), isAbiSupplied: false, isAbiValid: false, isBusy: false, isNameValid: false, name: null, tags: [] as string[] } as S; public state: S = this.defaultState; protected isContract?: boolean; public render (): React.ReactNode { const { isOpen, t } = this.props; return ( {t(this.headerText)} {this.renderContent()} {this.renderButtons()} ); } protected headerText = ''; protected renderContent: () => React.ReactNode | null = (): React.ReactNode => null; protected renderButtons: () => React.ReactNode | null = (): React.ReactNode => null; protected renderInputAbi (): React.ReactNode { const { t } = this.props; const { isBusy } = this.state; return ( ); } protected renderInputAccount (): React.ReactNode { const { t } = this.props; const { accountId, isBusy } = this.state; return ( ); } protected renderInputName (): React.ReactNode { const { isNew, t } = this.props; const { isBusy, isNameValid, name } = this.state; return ( ); } protected renderInputGas (): React.ReactNode { const { t } = this.props; const { gasLimit, isBusy } = this.state; const isGasValid = !gasLimit.isZero(); return ( ); } protected renderCancelButton (): React.ReactNode { const { t } = this.props; return ( <>