// 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 { SubmittableResult } from '@polkadot/api/SubmittableExtrinsic'; import { I18nProps } from '@polkadot/ui-app/types'; import { ComponentProps } from './types'; import BN from 'bn.js'; import React from 'react'; import { Button, Input, InputAddress, InputFile, InputNumber, TxButton } from '@polkadot/ui-app'; import { compactAddLength } from '@polkadot/util'; import { Hash } from '@polkadot/types'; import ABI from './ABI'; import ValidateCode from './ValidateCode'; import store from './store'; import translate from './translate'; type Props = ComponentProps & I18nProps; type State = { abi?: string | null, accountId?: string | null, codeHash?: string | null, gasLimit: BN, isAbiValid: boolean, isBusy: boolean, isCodeValid: boolean, isNameValid: boolean, isNew: boolean, isWasmValid: boolean, name?: string | null, wasm?: Uint8Array | null }; class Deploy extends React.PureComponent { state: State = { accountId: null, gasLimit: new BN(0), isAbiValid: true, isBusy: false, isCodeValid: false, isNew: true, isNameValid: false, isWasmValid: false }; render () { const { t } = this.props; const { isNew } = this.state; return (
); } private renderDeploy () { const { t } = this.props; const { accountId, gasLimit, isAbiValid, isBusy, isNameValid, isWasmValid, wasm } = this.state; const isValid = !isBusy && isAbiValid && isNameValid && isWasmValid && !gasLimit.isZero() && !!accountId; return ( <> {this.renderInputName()} {this.renderInputAbi()} ); } private renderExisting () { const { t } = this.props; const { codeHash, isAbiValid, isCodeValid, isNameValid } = this.state; const isValid = isAbiValid && isCodeValid && isNameValid; return ( <> {this.renderInputName()} {this.renderInputAbi()}