diff --git a/package.json b/package.json index 6b2e7b6be8..fe4d3e98c4 100644 --- a/package.json +++ b/package.json @@ -10,10 +10,10 @@ "packages/*" ], "resolutions": { - "@polkadot/api": "^0.90.0-beta.30", - "@polkadot/api-contract": "^0.90.0-beta.30", + "@polkadot/api": "^0.90.0-beta.31", + "@polkadot/api-contract": "^0.90.0-beta.31", "@polkadot/keyring": "^1.0.1", - "@polkadot/types": "^0.90.0-beta.30", + "@polkadot/types": "^0.90.0-beta.31", "@polkadot/util": "^1.0.1", "@polkadot/util-crypto": "^1.0.1", "@types/styled-components": "4.1.8", diff --git a/packages/app-contracts/package.json b/packages/app-contracts/package.json index afbbe6b970..b98c7cd320 100644 --- a/packages/app-contracts/package.json +++ b/packages/app-contracts/package.json @@ -11,7 +11,7 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.5.5", - "@polkadot/api-contract": "^0.90.0-beta.30", + "@polkadot/api-contract": "^0.90.0-beta.31", "@polkadot/ui-app": "^0.34.0-beta.111" } } diff --git a/packages/app-staking/src/Actions/Account/InputValidationSessionKey.tsx b/packages/app-staking/src/Actions/Account/InputValidationSessionKey.tsx index 445fc0574e..a625673bb5 100644 --- a/packages/app-staking/src/Actions/Account/InputValidationSessionKey.tsx +++ b/packages/app-staking/src/Actions/Account/InputValidationSessionKey.tsx @@ -12,7 +12,7 @@ import translate from '../../translate'; interface Props extends I18nProps { controllerId: string; onError: (error: string | null) => void; - sessionId: string; + sessionId: string | null; stashId: string; } diff --git a/packages/app-staking/src/Actions/Account/SetSessionAccount.tsx b/packages/app-staking/src/Actions/Account/SetSessionAccount.tsx index 496eee4f73..d7816ab3cc 100644 --- a/packages/app-staking/src/Actions/Account/SetSessionAccount.tsx +++ b/packages/app-staking/src/Actions/Account/SetSessionAccount.tsx @@ -6,7 +6,7 @@ import { ApiProps } from '@polkadot/ui-api/types'; import { I18nProps } from '@polkadot/ui-app/types'; import React from 'react'; -import { Button, InputAddress, Modal, TxButton } from '@polkadot/ui-app'; +import { Button, InputAddress, Input, Modal, TxButton } from '@polkadot/ui-app'; import { withApi, withMulti } from '@polkadot/ui-api'; import ValidationSessionKey from './InputValidationSessionKey'; @@ -21,13 +21,10 @@ type Props = I18nProps & ApiProps & { }; interface State { - babe: string; - babeError: string | null; - // TODO rename grandpa - ed25519: string; + // TODO remove once we drop v1 support + ed25519: string | null; ed25519Error: string | null; - imOnline: string; - imOnlineError: string | null; + keys: string | null; } class SetSessionKey extends React.PureComponent { @@ -37,24 +34,23 @@ class SetSessionKey extends React.PureComponent { super(props); this.state = { - babe: props.sessionIds[1] || props.controllerId, - babeError: null, ed25519: props.sessionIds[0] || props.controllerId, ed25519Error: null, - imOnline: props.sessionIds[2] || props.controllerId, - imOnlineError: null + keys: null }; } public render (): React.ReactNode { const { controllerId, isOpen, isSubstrateV2, onClose, t } = this.props; - const { ed25519, ed25519Error, babe, babeError, imOnline, imOnlineError } = this.state; + const { ed25519, ed25519Error, keys } = this.state; if (!isOpen) { return null; } - const hasError = !ed25519 || !!ed25519Error || (isSubstrateV2 ? ((!babe || !!babeError) && (!imOnline || !!imOnlineError)) : false); + const hasError = isSubstrateV2 + ? !keys + : (!ed25519 || !!ed25519Error); return ( { onClick={onClose} params={ isSubstrateV2 - ? [{ babe, grandpa: ed25519, imOnline }, new Uint8Array([])] + ? [keys, new Uint8Array([])] : [ed25519] } tx={ @@ -96,8 +92,7 @@ class SetSessionKey extends React.PureComponent { } private renderContent (): React.ReactNode { - const { controllerId, isSubstrateV2, stashId, t } = this.props; - const { ed25519, imOnline, babe } = this.state; + const { controllerId, isSubstrateV2, t } = this.props; return ( <> @@ -111,86 +106,67 @@ class SetSessionKey extends React.PureComponent { isDisabled label={t('controller account')} /> - - { isSubstrateV2 - ? ( - <> - - - - - - ) - : null + ? this.renderV2Keys() + : this.renderV1Keys() } - ); } - private onChangeBabe = (babe: string): void => { - this.setState({ babe }); + private renderV1Keys (): React.ReactNode { + const { controllerId, stashId, t } = this.props; + const { ed25519 } = this.state; + + return ( + <> + + + + ); } - private onChangeEd25519 = (ed25519: string): void => { + private renderV2Keys (): React.ReactNode { + const { t } = this.props; + const { keys } = this.state; + + return ( + <> + + + ); + } + + private onChangeEd25519 = (ed25519: string | null): void => { this.setState({ ed25519 }); } - private onChangeImOnline = (imOnline: string): void => { - this.setState({ imOnline }); - } - - private onSessionErrorBabe = (babeError: string | null): void => { - this.setState({ babeError }); + private onChangeKeys = (keys: string): void => { + this.setState({ keys: keys || null }); } private onSessionErrorEd25519 = (ed25519Error: string | null): void => { this.setState({ ed25519Error }); } - - private onSessionErrorImOnline = (imOnlineError: string | null): void => { - this.setState({ imOnlineError }); - } } export default withMulti( diff --git a/packages/ui-api/package.json b/packages/ui-api/package.json index 4c8d8c50cf..4da625ba39 100644 --- a/packages/ui-api/package.json +++ b/packages/ui-api/package.json @@ -31,7 +31,7 @@ "homepage": "https://github.com/polkadot-js/ui/tree/master/packages/ui-reactive#readme", "dependencies": { "@babel/runtime": "^7.5.5", - "@polkadot/api": "^0.90.0-beta.30", + "@polkadot/api": "^0.90.0-beta.31", "@polkadot/extension-dapp": "^0.6.1", "rxjs-compat": "^6.4.0" } diff --git a/packages/ui-app/src/InputAddressSimple.tsx b/packages/ui-app/src/InputAddressSimple.tsx new file mode 100644 index 0000000000..62bf1cf652 --- /dev/null +++ b/packages/ui-app/src/InputAddressSimple.tsx @@ -0,0 +1,73 @@ +// Copyright 2017-2019 @polkadot/ui-app 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 { BareProps } from './types'; + +import React from 'react'; +import styled from 'styled-components'; + +import addressToAddress from './util/toAddress'; +import IdentityIcon from './IdentityIcon'; +import Input from './Input'; + +interface Props extends BareProps { + help?: React.ReactNode; + label?: React.ReactNode; + onChange?: (address: string | null) => void; +} + +interface State { + address: string | null; + isError: boolean; +} + +class InputAddressSimple extends React.PureComponent { + public state: State = { + address: null, + isError: true + }; + + public render (): React.ReactNode { + const { className, help, label } = this.props; + const { address, isError } = this.state; + + return ( +
+ + +
+ ); + } + + private onChange = (_address: string): void => { + const { onChange } = this.props; + const address = addressToAddress(_address) || null; + + this.setState({ address, isError: !address }, (): void => { + onChange && onChange(address); + }); + } +} + +export default styled(InputAddressSimple)` + position: relative; + + .ui--InputAddressSimpleIcon { + background: #eee; + border: 1px solid #888; + border-radius: 50%; + left: 0.75rem; + position: absolute; + top: 1rem; + } +`; diff --git a/packages/ui-app/src/index.tsx b/packages/ui-app/src/index.tsx index 8665268434..2c20b23e97 100644 --- a/packages/ui-app/src/index.tsx +++ b/packages/ui-app/src/index.tsx @@ -34,6 +34,7 @@ export { default as IdentityIcon } from './IdentityIcon'; export { default as InfoForInput } from './InfoForInput'; export { default as Input } from './Input'; export { default as InputAddress } from './InputAddress'; +export { default as InputAddressSimple } from './InputAddressSimple'; export { default as InputBalance } from './InputBalance'; export { default as InputBalanceBonded } from './InputBalanceBonded'; export { default as InputConsts } from './InputConsts'; diff --git a/packages/ui-params/src/Param/Data.tsx b/packages/ui-params/src/Param/Data.tsx new file mode 100644 index 0000000000..38de5ad709 --- /dev/null +++ b/packages/ui-params/src/Param/Data.tsx @@ -0,0 +1,47 @@ +// Copyright 2017-2019 @polkadot/ui-app 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 { Props } from '../types'; + +import React from 'react'; +import { Input } from '@polkadot/ui-app'; + +import Bare from './Bare'; + +export default class Data extends React.PureComponent { + public render (): React.ReactNode { + const { className, defaultValue: { value }, isDisabled, isError, label, onEnter, style, withLabel } = this.props; + const defaultValue = value || ''; + + return ( + + + + ); + } + + private onChange = (value: string): void => { + const { onChange } = this.props; + const isValid = value.length !== 0; + + onChange && onChange({ + isValid, + value + }); + } +} diff --git a/packages/ui-params/src/Param/findComponent.ts b/packages/ui-params/src/Param/findComponent.ts index c9b9c8eaca..f670cd5890 100644 --- a/packages/ui-params/src/Param/findComponent.ts +++ b/packages/ui-params/src/Param/findComponent.ts @@ -14,6 +14,7 @@ import Balance from './Balance'; import Bool from './Bool'; import Bytes from './Bytes'; import Code from './Code'; +import Data from './Data'; import Enum from './Enum'; import Hash from './Hash'; import Moment from './Moment'; @@ -41,6 +42,7 @@ const components: ComponentMap = ([ { c: Bool, t: ['bool'] }, { c: Bytes, t: ['Bytes'] }, { c: Code, t: ['Code'] }, + { c: Data, t: ['Data', 'Keys'] }, { c: Enum, t: ['Enum'] }, { c: Hash, t: ['CodeHash', 'Hash', 'SeedOf', 'Signature'] }, { c: KeyValue, t: ['KeyValue'] }, diff --git a/packages/ui-params/src/initValue.ts b/packages/ui-params/src/initValue.ts index 2c38573c07..58a1c76005 100644 --- a/packages/ui-params/src/initValue.ts +++ b/packages/ui-params/src/initValue.ts @@ -75,6 +75,10 @@ export default function getInitValue (def: TypeDef): RawParamValue | RawParamVal case 'Hash': return createType('Hash'); + case 'Data': + case 'Keys': + return ''; + case 'AccountId': case 'AccountIdOf': case 'Address': @@ -112,7 +116,7 @@ export default function getInitValue (def: TypeDef): RawParamValue | RawParamVal } console.error(`Unable to determine default type for ${JSON.stringify(def)}`); - return void 0; + return '0x'; } } } diff --git a/yarn.lock b/yarn.lock index f9a214609f..2f150007ae 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1931,44 +1931,44 @@ universal-user-agent "^3.0.0" url-template "^2.0.8" -"@polkadot/api-contract@^0.90.0-beta.30": - version "0.90.0-beta.30" - resolved "https://registry.yarnpkg.com/@polkadot/api-contract/-/api-contract-0.90.0-beta.30.tgz#bba855f02d9a77651a0d934224365bc4026a47d6" - integrity sha512-lV3UCNMJuJNoRq3EmFfJd6fxeQkv6Ywi6SgvwWmBuxAuTGOyarc0M2uMsaCXAaRhQiynhKXKeiHdNTkLgvRFwQ== +"@polkadot/api-contract@^0.90.0-beta.31": + version "0.90.0-beta.31" + resolved "https://registry.yarnpkg.com/@polkadot/api-contract/-/api-contract-0.90.0-beta.31.tgz#b484e7ac1e36b45e5769ee7dc1b32b88f4e6abb8" + integrity sha512-aXunLiPX53lD7FJGnaybBv1jtZFsYAOLfL9rVoZnKX3ye5uKaPMmZ7NvdrTWXLJsyv2XyrMnqiKPITUrNIo0PQ== dependencies: "@babel/runtime" "^7.5.5" - "@polkadot/types" "^0.90.0-beta.30" + "@polkadot/types" "^0.90.0-beta.31" -"@polkadot/api-derive@^0.90.0-beta.30": - version "0.90.0-beta.30" - resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-0.90.0-beta.30.tgz#0f1658d58698c779da535c9e970e7ef70a0f3811" - integrity sha512-Ji0q15F3E5b2LnA6nW58KAYkvq34CGCYXayT8pAm1f6the/3qCrT8rh7XXY4adqzs/Lyk8ICaEWJxtDfT/e5qA== +"@polkadot/api-derive@^0.90.0-beta.31": + version "0.90.0-beta.31" + resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-0.90.0-beta.31.tgz#5457db993429ae40e283e425c1b670fe811b658d" + integrity sha512-Eo/j88GE4EY/IKUjXVFJo1nIGjUY9HSEmD8lVqRK24ZTwaNuRB6ToPlCW0HbBPz8qNFrX7iGBXF0sGP3Ih01AA== dependencies: "@babel/runtime" "^7.5.5" - "@polkadot/api" "^0.90.0-beta.30" - "@polkadot/types" "^0.90.0-beta.30" + "@polkadot/api" "^0.90.0-beta.31" + "@polkadot/types" "^0.90.0-beta.31" -"@polkadot/api-metadata@^0.90.0-beta.30": - version "0.90.0-beta.30" - resolved "https://registry.yarnpkg.com/@polkadot/api-metadata/-/api-metadata-0.90.0-beta.30.tgz#2f38b955d6091b83b5bcad16a9f12df267f4558e" - integrity sha512-9uhdWOIKp80t60DAeEkqbEZoP82ZOr9kuk/4xLKccD76aNr0G9ywnHIDJVazXVITFU4uQx0ptHjfHaXR8RkGWA== +"@polkadot/api-metadata@^0.90.0-beta.31": + version "0.90.0-beta.31" + resolved "https://registry.yarnpkg.com/@polkadot/api-metadata/-/api-metadata-0.90.0-beta.31.tgz#dfb70a3af5375a2a5a9649496a5388c59121b8ed" + integrity sha512-mKkz7e1fBEBbZeZiCWJj4OzDvbKbCsqtsMsY8j5oMNP+5RD4O29pXYp9T52pFJkJPrGmKp41MEF0GpyAzLci2A== dependencies: "@babel/runtime" "^7.5.5" - "@polkadot/types" "^0.90.0-beta.30" + "@polkadot/types" "^0.90.0-beta.31" "@polkadot/util" "^1.0.1" "@polkadot/util-crypto" "^1.0.1" -"@polkadot/api@^0.90.0-beta.30": - version "0.90.0-beta.30" - resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-0.90.0-beta.30.tgz#9fd1f3f8646cc696e21a1b5dde2002c0b6bd1c36" - integrity sha512-Ysut9XmZJ+Qiftvakgi38oMgKeBE1+GENz2JWDQ2NcMR4JTKbSTKdXy0I1PZv6SFVnHMG698cBRYoqYeu+hI+w== +"@polkadot/api@^0.90.0-beta.31": + version "0.90.0-beta.31" + resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-0.90.0-beta.31.tgz#cacdcee528e0d12ee76545defe64c6e4b155414b" + integrity sha512-e+0kV5h3aRW7npd2NbZxYHac2Zp9V0+CPHiWjJFgWjPTxY4M7GOBth5BVqwp7dXC2re7T6Q2w8CqOpIV271yFw== dependencies: "@babel/runtime" "^7.5.5" - "@polkadot/api-derive" "^0.90.0-beta.30" - "@polkadot/api-metadata" "^0.90.0-beta.30" - "@polkadot/rpc-core" "^0.90.0-beta.30" - "@polkadot/rpc-provider" "^0.90.0-beta.30" - "@polkadot/types" "^0.90.0-beta.30" + "@polkadot/api-derive" "^0.90.0-beta.31" + "@polkadot/api-metadata" "^0.90.0-beta.31" + "@polkadot/rpc-core" "^0.90.0-beta.31" + "@polkadot/rpc-provider" "^0.90.0-beta.31" + "@polkadot/types" "^0.90.0-beta.31" "@polkadot/util-crypto" "^1.0.1" "@polkadot/dev-react@^0.30.0-beta.26": @@ -2071,10 +2071,10 @@ dependencies: "@babel/runtime" "^7.5.5" -"@polkadot/jsonrpc@^0.90.0-beta.30": - version "0.90.0-beta.30" - resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-0.90.0-beta.30.tgz#39e185e5d75e76ba929e836e0fc8d79c9ff71b41" - integrity sha512-8VP+XvlFgzf8q7ybWwFopOpMql+iQgwUsjYh7PBFlA7PArl2Remjm12TZsDIDhO5Yz+o9bPBP1D66PH3xwDC2w== +"@polkadot/jsonrpc@^0.90.0-beta.31": + version "0.90.0-beta.31" + resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-0.90.0-beta.31.tgz#f617c24ff545c7339d31389e69378d53cce9281b" + integrity sha512-9PiMoARAXyjZPcNHY2rMQqL5jaUQBPZtQYIDQn+mQphkjd2PntruWe6u8kGP39FV3cOgc+ketgl01U8i9Sr6sQ== dependencies: "@babel/runtime" "^7.5.5" @@ -2102,25 +2102,25 @@ react-copy-to-clipboard "^5.0.1" styled-components "^4.3.1" -"@polkadot/rpc-core@^0.90.0-beta.30": - version "0.90.0-beta.30" - resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-0.90.0-beta.30.tgz#6c17fd8158d65e689d41d8f46048ccfd2b6d3bdb" - integrity sha512-o2hV0q5js0VgtcT4f9yZ72QZ+lyrNxQVpCdJrZb7dmDTv5ulZyhPUqmJCx2k7DShRXLVszTQQTtYLIva6vg67w== +"@polkadot/rpc-core@^0.90.0-beta.31": + version "0.90.0-beta.31" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-0.90.0-beta.31.tgz#786a99911df567f65b8de146bc89ba94274abfc3" + integrity sha512-P6RQSKnVB42w4BstS/JMnOvjpDmmb6v7yALCJE6brp5lhy0y7Is14s2ZUXkD8dCQyf+RiHm8J8hud8UIJy9uwQ== dependencies: "@babel/runtime" "^7.5.5" - "@polkadot/jsonrpc" "^0.90.0-beta.30" - "@polkadot/rpc-provider" "^0.90.0-beta.30" - "@polkadot/types" "^0.90.0-beta.30" + "@polkadot/jsonrpc" "^0.90.0-beta.31" + "@polkadot/rpc-provider" "^0.90.0-beta.31" + "@polkadot/types" "^0.90.0-beta.31" "@polkadot/util" "^1.0.1" rxjs "^6.5.2" -"@polkadot/rpc-provider@^0.90.0-beta.30": - version "0.90.0-beta.30" - resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-0.90.0-beta.30.tgz#1bfce4e43100255cefa496f74c6a7221ce49df40" - integrity sha512-CiUUo/9XtlR9P5+9habwFexfssJN1xyJ1Hr+IZ+kS9B6aLiwOOTvlUNjyp99iksDpTQEYUrCj6lBnsYge/P1bg== +"@polkadot/rpc-provider@^0.90.0-beta.31": + version "0.90.0-beta.31" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-0.90.0-beta.31.tgz#04d543e1fe3840275e8eba1247f5ef3ed76d74d7" + integrity sha512-lv/7aK9VQLdTBX6/WJaeTGuhvK9N1CnMyXBDTrqgzokW2j9tewLIAyNiuWO34pr+sb4zdJp22dHZ+1Fp5K//Zg== dependencies: "@babel/runtime" "^7.5.5" - "@polkadot/api-metadata" "^0.90.0-beta.30" + "@polkadot/api-metadata" "^0.90.0-beta.31" "@polkadot/util" "^1.0.1" "@polkadot/util-crypto" "^1.0.1" "@types/nock" "^10.0.3" @@ -2135,10 +2135,10 @@ dependencies: "@types/chrome" "^0.0.86" -"@polkadot/types@^0.90.0-beta.30": - version "0.90.0-beta.30" - resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-0.90.0-beta.30.tgz#7d619dcaf45fd2d3a8f6081dc97f06901f33f91c" - integrity sha512-SzkfCmi8gZSfSRU8tIyvl80XE7cxOUdWUiJMZS4LmI8pAELSaCjdhaBcfjUcYuzpbtsS8PfTVf1RPvALTs4rUQ== +"@polkadot/types@^0.90.0-beta.31": + version "0.90.0-beta.31" + resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-0.90.0-beta.31.tgz#54d43c1615705b92c02ad399b0b357130654d7db" + integrity sha512-/OvEfl+5eC40lfZsTsV5ssWigU0Nmu0PyOselt/XZ9eyyblV6I3mdJ/ws+pBl2o+IBnFXHwEwiZV3b0ueM8a3g== dependencies: "@babel/runtime" "^7.5.5" "@polkadot/util" "^1.0.1"