// Copyright 2017-2019 @polkadot/app-toolbox 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 as Props } from '@polkadot/ui-app/types'; import { KeyringPair } from '@polkadot/keyring/types'; import React from 'react'; import { Button , Input, InputAddress, Output, Static } from '@polkadot/ui-app'; import keyring from '@polkadot/ui-keyring'; import { hexToU8a, isHex, stringToU8a, u8aToHex } from '@polkadot/util'; import Unlock from './Unlock'; import translate from './translate'; type State = { currentPair: KeyringPair | null, defaultValue?: string, data: string, isHexData: boolean, isLocked: boolean, isUnlockVisible: boolean, signature: string }; class Sign extends React.PureComponent { state: State; constructor (props: Props) { super(props); const pairs = keyring.getPairs(); const currentPair = pairs[0] || null; this.state = { currentPair, defaultValue: currentPair ? currentPair.address() : void 0, data: '', isHexData: false, isLocked: currentPair ? currentPair.isLocked() : false, isUnlockVisible: false, signature: '' }; } render () { return (
{this.renderAccount()} {this.renderInput()} {this.renderSignature()} {this.renderUnlock()} {this.renderButtons()}
); } renderAccount () { const { t } = this.props; const { defaultValue } = this.state; return (
); } renderButtons () { const { t } = this.props; const { isLocked } = this.state; if (!isLocked) { return null; } return (