diff --git a/.babelrc.js b/.babelrc.js new file mode 100644 index 0000000000..5188ea0422 --- /dev/null +++ b/.babelrc.js @@ -0,0 +1 @@ +module.exports = require('./babel.config.js'); diff --git a/.flowconfig b/.flowconfig deleted file mode 100644 index fec98e1ad2..0000000000 --- a/.flowconfig +++ /dev/null @@ -1,18 +0,0 @@ -[ignore] -/build -/packages/.*/build - -[include] - -[libs] -node_modules/@polkadot/dev/flow-typed -node_modules/@polkadot/dev-react/flow-typed - -[lints] -all=warn - -[options] -include_warnings=true -module.name_mapper='^@polkadot/app-\(accounts\|addresses\|explorer\|extrinsics\|home\|rpc\|settings\|storage\|toolbox\|vanitygen\)\(.*\)$' -> '/packages/app-\1/src\2' -module.name_mapper='^@polkadot/apps\(.*\)$' -> '/packages/apps/src\1' -module.name_mapper='^@polkadot/ui-\(app\|identicon\|keyring\|react-rx\|react\|signer\)\(.*\)$' -> '/packages/ui-\1/src\2' diff --git a/flow-typed/semantic-ui-react.js b/flow-typed/semantic-ui-react.js deleted file mode 100644 index 4f757e1b38..0000000000 --- a/flow-typed/semantic-ui-react.js +++ /dev/null @@ -1,46 +0,0 @@ -// @flow - -declare module 'semantic-ui-react/dist/es/collections/Menu' { - declare module.exports: React$StatelessFunctionalComponent<*> & { - Item: React$StatelessFunctionalComponent<*> - }; -} - -declare module 'semantic-ui-react/dist/es/elements/Button' { - declare module.exports: React$StatelessFunctionalComponent<*> & { - Group: React$StatelessFunctionalComponent<*>, - Or: React$StatelessFunctionalComponent<*> - }; -} - -declare module 'semantic-ui-react/dist/es/elements/Divider' { - declare module.exports: React$StatelessFunctionalComponent<*>; -} - -declare module 'semantic-ui-react/dist/es/elements/Icon' { - declare module.exports: React$StatelessFunctionalComponent<*>; -} - -declare module 'semantic-ui-react/dist/es/elements/Input' { - declare module.exports: React$StatelessFunctionalComponent<*>; -} - -declare module 'semantic-ui-react/dist/es/elements/Label' { - declare module.exports: React$StatelessFunctionalComponent<*>; -} - -declare module 'semantic-ui-react/dist/es/modules/Dropdown' { - declare module.exports: React$StatelessFunctionalComponent<*> & { - Divider: React$StatelessFunctionalComponent<*>, - Header: React$StatelessFunctionalComponent<*>, - Item: React$StatelessFunctionalComponent<*> - }; -} - -declare module 'semantic-ui-react/dist/es/modules/Modal' { - declare module.exports: React$StatelessFunctionalComponent<*> & { - Actions: React$StatelessFunctionalComponent<*>, - Content: React$StatelessFunctionalComponent<*>, - Header: React$StatelessFunctionalComponent<*> - }; -} diff --git a/flow-typed/semver.js b/flow-typed/semver.js deleted file mode 100644 index 6c93a6aba5..0000000000 --- a/flow-typed/semver.js +++ /dev/null @@ -1,8 +0,0 @@ -// @flow - -declare module 'semver' { - declare module.exports: { - gt: (a: string, b: string) => boolean, - lt: (a: string, b: string) => boolean - } -} diff --git a/flow-typed/sodium.js b/flow-typed/sodium.js deleted file mode 100644 index 9c664aa350..0000000000 --- a/flow-typed/sodium.js +++ /dev/null @@ -1,15 +0,0 @@ -// @flow - -declare module 'sodium' { - declare module.exports: { - Key: { - Sign: { - fromSeed (seed: Buffer): { - getPublicKey (): { - baseBuffer: Buffer - } - } - } - } - } -} diff --git a/flow-typed/store.js b/flow-typed/store.js deleted file mode 100644 index 7a2a96230d..0000000000 --- a/flow-typed/store.js +++ /dev/null @@ -1,10 +0,0 @@ -// @flow - -declare module 'store' { - declare module.exports: { - each: (fn: (value: any, key: string) => void) => void, - get: (key: string) => any, - remove: (key: string) => any, - set: (key: string, value: any) => void, - } -} diff --git a/lerna.json b/lerna.json index 9876cabc13..1eb35a9287 100644 --- a/lerna.json +++ b/lerna.json @@ -10,5 +10,5 @@ "packages": [ "packages/*" ], - "version": "0.17.15" + "version": "0.18.0" } diff --git a/package.json b/package.json index 0de0fbf1e1..f1451d632c 100644 --- a/package.json +++ b/package.json @@ -10,20 +10,21 @@ "packages/*" ], "scripts": { - "build": "polkadot-dev-build-babel", - "check": "eslint packages && flow check", + "build": "polkadot-dev-build-ts", + "check": "tsc --noEmit", "clean": "polkadot-dev-clean-build", + "postinstall": "polkadot-dev-yarn-only", + "test": "jest --coverage", "demo:identicon": "webpack-serve --config packages/ui-identicon/webpack.config.js --content packages/ui-identicon --port 3000", "demo:rx": "webpack-serve --config packages/ui-react-rx/webpack.config.js --content packages/ui-react-rx --port 3000", "demo:ui": "webpack-serve --config packages/ui-react/webpack.config.js --content packages/ui-react --port 3000", "deploy:ghpages": "gh-pages -d packages/apps/build", - "postinstall": "polkadot-dev-yarn-only", "vanitygen": "polkadot-dev-build-babel && node packages/app-vanitygen/build/generator/cli.js", - "start": "cd packages/apps && webpack-serve --config webpack.config.js --port 3000", - "test": "jest --coverage" + "start": "cd packages/apps && webpack-serve --config webpack.config.js --port 3000" }, "devDependencies": { - "@polkadot/dev-react": "^0.19.25", + "@polkadot/dev-react": "^0.20.3", + "@polkadot/ts": "^0.1.2", "autoprefixer": "^8.6.2", "gh-pages": "^1.1.0", "postcss-import": "^11.1.0", diff --git a/packages/app-accounts/package.json b/packages/app-accounts/package.json index 850765299e..2010f970eb 100644 --- a/packages/app-accounts/package.json +++ b/packages/app-accounts/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/app-accounts", - "version": "0.17.15", + "version": "0.18.0", "main": "index.js", "repository": "https://github.com/polkadot-js/apps.git", "author": "Jaco Greeff ", @@ -15,7 +15,7 @@ "test": "jest --coverage" }, "dependencies": { - "@babel/runtime": "^7.0.0-beta.47", - "@polkadot/ui-app": "^0.17.15" + "@babel/runtime": "^7.0.0-beta.51", + "@polkadot/ui-app": "^0.18.0" } } diff --git a/packages/app-accounts/src/Address.js b/packages/app-accounts/src/Address.tsx similarity index 94% rename from packages/app-accounts/src/Address.js rename to packages/app-accounts/src/Address.tsx index 448968a63f..6414fde6d2 100644 --- a/packages/app-accounts/src/Address.js +++ b/packages/app-accounts/src/Address.tsx @@ -1,9 +1,8 @@ // Copyright 2017-2018 @polkadot/app-accounts authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { BareProps } from '@polkadot/ui-app/types'; +import { BareProps } from '@polkadot/ui-app/types'; import React from 'react'; @@ -30,7 +29,7 @@ const DEFAULT_ADDR = '5'.padEnd(16, 'x'); const DEFAULT_SHORT = `${DEFAULT_ADDR.slice(0, 7)}…${DEFAULT_ADDR.slice(-7)}`; export default class Address extends React.PureComponent { - state: State = ({}: $Shape); + state: State = {} as State; static getDerivedStateFromProps ({ value }: Props, { address, publicKey, shortValue }: State): State { try { @@ -51,7 +50,7 @@ export default class Address extends React.PureComponent { }; } - render (): React$Node { + render () { const { className, style } = this.props; const { address, isValid, shortValue } = this.state; @@ -76,7 +75,7 @@ export default class Address extends React.PureComponent { ); } - renderBalance (): React$Node { + renderBalance () { const { isValid, publicKey } = this.state; if (!isValid) { diff --git a/packages/app-accounts/src/Creator.js b/packages/app-accounts/src/Creator.tsx similarity index 92% rename from packages/app-accounts/src/Creator.js rename to packages/app-accounts/src/Creator.tsx index c8c857cdc7..a49606a38d 100644 --- a/packages/app-accounts/src/Creator.js +++ b/packages/app-accounts/src/Creator.tsx @@ -1,9 +1,8 @@ // Copyright 2017-2018 @polkadot/app-accounts authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { I18nProps } from '@polkadot/ui-app/types'; +import { I18nProps } from '@polkadot/ui-app/types'; import React from 'react'; @@ -11,7 +10,7 @@ import Button from '@polkadot/ui-app/Button'; import Input from '@polkadot/ui-app/Input'; import Password from '@polkadot/ui-app/Password'; import classes from '@polkadot/ui-app/util/classes'; -import keyring from '@polkadot/ui-keyring'; +import keyring from '@polkadot/ui-keyring/index'; import isHex from '@polkadot/util/is/hex'; import hexToU8a from '@polkadot/util/hex/toU8a'; import u8aFromString from '@polkadot/util/u8a/fromString'; @@ -41,7 +40,7 @@ type State = { function formatSeed (seed: string): Uint8Array { return isHex(seed) ? hexToU8a(seed) - : u8aFromString(seed.padEnd(32, ' ')); + : u8aFromString((seed as string).padEnd(32, ' ')); } function addressFromSeed (seed: string): string { @@ -61,7 +60,7 @@ class Creator extends React.PureComponent { this.state = this.emptyState(); } - render (): React$Node { + render () { const { className, style } = this.props; const { address, isSeedValid } = this.state; @@ -86,7 +85,7 @@ class Creator extends React.PureComponent { ); } - renderButtons (): React$Node { + renderButtons () { const { t } = this.props; const { isValid } = this.state; @@ -110,7 +109,7 @@ class Creator extends React.PureComponent { ); } - renderInput (): React$Node { + renderInput () { const { t } = this.props; const { isNameValid, isPassValid, isSeedValid, name, password, seed } = this.state; @@ -169,7 +168,7 @@ class Creator extends React.PureComponent { }; } - nextState (newState: $Shape): void { + nextState (newState: State): void { this.setState( (prevState: State, props: Props): State => { const { name = prevState.name, password = prevState.password, seed = prevState.seed } = newState; @@ -177,7 +176,7 @@ class Creator extends React.PureComponent { const isNameValid = !!name; const isSeedValid = isHex(seed) ? seed.length === 66 - : seed.length <= 32; + : (seed as string).length <= 32; const isPassValid = password.length > 0 && password.length <= 32; if (isSeedValid && seed !== prevState.seed) { @@ -199,15 +198,15 @@ class Creator extends React.PureComponent { } onChangeSeed = (seed: string): void => { - this.nextState({ seed }); + this.nextState({ seed } as State); } onChangeName = (name: string): void => { - this.nextState({ name }); + this.nextState({ name } as State); } onChangePass = (password: string): void => { - this.nextState({ password }); + this.nextState({ password } as State); } onCommit = (): void => { diff --git a/packages/app-accounts/src/Editor.js b/packages/app-accounts/src/Editor.tsx similarity index 91% rename from packages/app-accounts/src/Editor.js rename to packages/app-accounts/src/Editor.tsx index 0056b7bb94..e7435e647c 100644 --- a/packages/app-accounts/src/Editor.js +++ b/packages/app-accounts/src/Editor.tsx @@ -1,10 +1,9 @@ // Copyright 2017-2018 @polkadot/app-accounts authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { KeyringPair } from '@polkadot/util-keyring/types'; -import type { I18nProps } from '@polkadot/ui-app/types'; +import { KeyringPair } from '@polkadot/util-keyring/types'; +import { I18nProps } from '@polkadot/ui-app/types'; import React from 'react'; @@ -12,7 +11,7 @@ import Button from '@polkadot/ui-app/Button'; import Input from '@polkadot/ui-app/Input'; import InputAddress from '@polkadot/ui-app/InputAddress'; import classes from '@polkadot/ui-app/util/classes'; -import keyring from '@polkadot/ui-keyring'; +import keyring from '@polkadot/ui-keyring/index'; import Address from './Address'; import translate from './translate'; @@ -43,7 +42,7 @@ class Editor extends React.PureComponent { : void 0; } - render (): React$Node { + render () { const { className, style } = this.props; return ( @@ -57,7 +56,7 @@ class Editor extends React.PureComponent { ); } - renderButtons (): React$Node { + renderButtons () { const { t } = this.props; const { currentPair, isEdited } = this.state; @@ -94,7 +93,7 @@ class Editor extends React.PureComponent { ); } - renderData (): React$Node { + renderData () { const { t } = this.props; const { currentPair, defaultValue, editedName } = this.state; @@ -143,7 +142,7 @@ class Editor extends React.PureComponent { ); } - createState (currentPair: KeyringPair | null): $Shape { + createState (currentPair: KeyringPair | null): State { return { currentPair, editedName: currentPair @@ -153,9 +152,9 @@ class Editor extends React.PureComponent { }; } - nextState (newState?: $Shape = {}): void { + nextState (newState: State = {} as State): void { this.setState( - (prevState: State): $Shape => { + (prevState: State): State => { let { currentPair = prevState.currentPair, editedName = prevState.editedName } = newState; const previous = prevState.currentPair || { address: () => null }; let isEdited = false; @@ -184,11 +183,11 @@ class Editor extends React.PureComponent { this.nextState({ currentPair - }); + } as State); } onChangeName = (editedName: string): void => { - this.nextState({ editedName }); + this.nextState({ editedName } as State); } onCommit = (): void => { @@ -203,7 +202,7 @@ class Editor extends React.PureComponent { whenEdited: Date.now() }); - this.nextState({}); + this.nextState({} as State); } onDiscard = (): void => { @@ -215,7 +214,7 @@ class Editor extends React.PureComponent { this.nextState({ editedName: currentPair.getMeta().name - }); + } as State); } onForget = (): void => { @@ -239,7 +238,7 @@ class Editor extends React.PureComponent { this.nextState({ currentPair: nextPair, defaultValue - }); + } as State); } } diff --git a/packages/app-accounts/src/index.js b/packages/app-accounts/src/index.tsx similarity index 92% rename from packages/app-accounts/src/index.js rename to packages/app-accounts/src/index.tsx index 4447dc7fff..f982cf34b5 100644 --- a/packages/app-accounts/src/index.js +++ b/packages/app-accounts/src/index.tsx @@ -1,9 +1,8 @@ // Copyright 2017-2018 @polkadot/app-accounts authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { I18nProps } from '@polkadot/ui-app/types'; +import { I18nProps } from '@polkadot/ui-app/types'; import './index.css'; @@ -25,7 +24,7 @@ type State = { } // FIXME React-router would probably be the best route, not home-grown -const Components: { [Actions]: React$ComponentType<{}> } = { +const Components: { [index: string]: React.ComponentType } = { 'create': Creator, 'edit': Editor }; @@ -33,7 +32,7 @@ const Components: { [Actions]: React$ComponentType<{}> } = { class AccountsApp extends React.PureComponent { state: State = { action: 'edit' }; - render (): React$Node { + render () { const { className, style, t } = this.props; const { action } = this.state; const Component = Components[action]; diff --git a/packages/app-accounts/src/translate.js b/packages/app-accounts/src/translate.ts similarity index 96% rename from packages/app-accounts/src/translate.js rename to packages/app-accounts/src/translate.ts index ffb7460678..1a7bdfa204 100644 --- a/packages/app-accounts/src/translate.js +++ b/packages/app-accounts/src/translate.ts @@ -1,7 +1,6 @@ // Copyright 2017-2018 @polkadot/app-accounts authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow import { translate } from 'react-i18next'; diff --git a/packages/app-addresses/package.json b/packages/app-addresses/package.json index 50d2eaeb1c..f644f92713 100644 --- a/packages/app-addresses/package.json +++ b/packages/app-addresses/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/app-addresses", - "version": "0.17.15", + "version": "0.18.0", "main": "index.js", "repository": "https://github.com/polkadot-js/apps.git", "author": "Jaco Greeff ", @@ -15,8 +15,8 @@ "test": "jest --coverage" }, "dependencies": { - "@babel/runtime": "^7.0.0-beta.47", - "@polkadot/app-accounts": "^0.17.15", - "@polkadot/ui-app": "^0.17.15" + "@babel/runtime": "^7.0.0-beta.51", + "@polkadot/app-accounts": "^0.18.0", + "@polkadot/ui-app": "^0.18.0" } } diff --git a/packages/app-addresses/src/Creator.js b/packages/app-addresses/src/Creator.tsx similarity index 92% rename from packages/app-addresses/src/Creator.js rename to packages/app-addresses/src/Creator.tsx index 1e8a76f01d..466d7d586a 100644 --- a/packages/app-addresses/src/Creator.js +++ b/packages/app-addresses/src/Creator.tsx @@ -1,16 +1,15 @@ // Copyright 2017-2018 @polkadot/app-addresses authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { I18nProps } from '@polkadot/ui-app/types'; +import { I18nProps } from '@polkadot/ui-app/types'; import React from 'react'; import Button from '@polkadot/ui-app/Button'; import Input from '@polkadot/ui-app/Input'; import classes from '@polkadot/ui-app/util/classes'; -import keyring from '@polkadot/ui-keyring'; +import keyring from '@polkadot/ui-keyring/index'; import addressDecode from '@polkadot/util-keyring/address/decode'; import addressEncode from '@polkadot/util-keyring/address/encode'; @@ -38,7 +37,7 @@ class Creator extends React.PureComponent { this.state = this.emptyState(); } - render (): React$Node { + render () { const { className, style } = this.props; const { address } = this.state; @@ -59,7 +58,7 @@ class Creator extends React.PureComponent { ); } - renderButtons (): React$Node { + renderButtons () { const { t } = this.props; const { isValid } = this.state; @@ -83,7 +82,7 @@ class Creator extends React.PureComponent { ); } - renderInput (): React$Node { + renderInput () { const { t } = this.props; const { address, isAddressValid, isNameValid, name } = this.state; @@ -125,7 +124,7 @@ class Creator extends React.PureComponent { }; } - nextState (newState: $Shape): void { + nextState (newState: State): void { this.setState( (prevState: State, props: Props): State => { const { address = prevState.address, name = prevState.name } = newState; @@ -156,11 +155,11 @@ class Creator extends React.PureComponent { } onChangeAddress = (address: string): void => { - this.nextState({ address }); + this.nextState({ address } as State); } onChangeName = (name: string): void => { - this.nextState({ name }); + this.nextState({ name } as State); } onCommit = (): void => { diff --git a/packages/app-addresses/src/Editor.js b/packages/app-addresses/src/Editor.tsx similarity index 91% rename from packages/app-addresses/src/Editor.js rename to packages/app-addresses/src/Editor.tsx index 4dcf9c2e62..28d1b8b34d 100644 --- a/packages/app-addresses/src/Editor.js +++ b/packages/app-addresses/src/Editor.tsx @@ -1,10 +1,9 @@ // Copyright 2017-2018 @polkadot/app-addresses authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { KeyringAddress } from '@polkadot/ui-keyring/types'; -import type { I18nProps } from '@polkadot/ui-app/types'; +import { KeyringAddress } from '@polkadot/ui-keyring/types'; +import { I18nProps } from '@polkadot/ui-app/types'; import React from 'react'; @@ -12,7 +11,7 @@ import Button from '@polkadot/ui-app/Button'; import Input from '@polkadot/ui-app/Input'; import InputAddress from '@polkadot/ui-app/InputAddress'; import classes from '@polkadot/ui-app/util/classes'; -import keyring from '@polkadot/ui-keyring'; +import keyring from '@polkadot/ui-keyring/index'; import Address from '@polkadot/app-accounts/Address'; import translate from './translate'; @@ -43,7 +42,7 @@ class Editor extends React.PureComponent { : void 0; } - render (): React$Node { + render () { const { className, style } = this.props; return ( @@ -57,7 +56,7 @@ class Editor extends React.PureComponent { ); } - renderButtons (): React$Node { + renderButtons () { const { t } = this.props; const { currentAddress, isEdited } = this.state; @@ -94,7 +93,7 @@ class Editor extends React.PureComponent { ); } - renderData (): React$Node { + renderData () { const { t } = this.props; const { currentAddress, defaultValue, editedName } = this.state; @@ -142,7 +141,7 @@ class Editor extends React.PureComponent { ); } - createState (currentAddress: KeyringAddress | null): $Shape { + createState (currentAddress: KeyringAddress | null): State { const { name = '' } = currentAddress ? currentAddress.getMeta() : {}; @@ -154,7 +153,7 @@ class Editor extends React.PureComponent { }; } - nextState (newState?: $Shape = {}): void { + nextState (newState: State = {} as State): void { this.setState( (prevState: State): State => { let { currentAddress = prevState.currentAddress, editedName = prevState.editedName } = newState; @@ -183,13 +182,11 @@ class Editor extends React.PureComponent { onChangeAddress = (publicKey: Uint8Array): void => { const currentAddress = keyring.getAddress(publicKey) || null; - this.nextState({ - currentAddress - }); + this.nextState({ currentAddress } as State); } onChangeName = (editedName: string): void => { - this.nextState({ editedName }); + this.nextState({ editedName } as State); } onCommit = (): void => { @@ -204,7 +201,7 @@ class Editor extends React.PureComponent { whenEdited: Date.now() }); - this.nextState({}); + this.nextState({} as State); } onDiscard = (): void => { @@ -216,7 +213,7 @@ class Editor extends React.PureComponent { this.nextState({ editedName: currentAddress.getMeta().name - }); + } as State); } onForget = (): void => { @@ -240,7 +237,7 @@ class Editor extends React.PureComponent { this.nextState({ currentAddress: nextAddress, defaultValue - }); + } as State); } } diff --git a/packages/app-addresses/src/index.js b/packages/app-addresses/src/index.tsx similarity index 92% rename from packages/app-addresses/src/index.js rename to packages/app-addresses/src/index.tsx index 65664a6526..8988a7eb73 100644 --- a/packages/app-addresses/src/index.js +++ b/packages/app-addresses/src/index.tsx @@ -1,9 +1,8 @@ // Copyright 2017-2018 @polkadot/app-addresses authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { I18nProps } from '@polkadot/ui-app/types'; +import { I18nProps } from '@polkadot/ui-app/types'; import './index.css'; @@ -25,7 +24,7 @@ type State = { } // FIXME React-router would probably be the best route, not home-grown -const Components: { [Actions]: React$ComponentType<{}> } = { +const Components: { [index: string]: React.ComponentType } = { 'create': Creator, 'edit': Editor }; @@ -33,7 +32,7 @@ const Components: { [Actions]: React$ComponentType<{}> } = { class AddressesApp extends React.PureComponent { state: State = { action: 'edit' }; - render (): React$Node { + render () { const { className, style, t } = this.props; const { action } = this.state; const Component = Components[action]; diff --git a/packages/app-addresses/src/translate.js b/packages/app-addresses/src/translate.ts similarity index 96% rename from packages/app-addresses/src/translate.js rename to packages/app-addresses/src/translate.ts index 9b3ce0fddb..a2f6a8db2b 100644 --- a/packages/app-addresses/src/translate.js +++ b/packages/app-addresses/src/translate.ts @@ -1,7 +1,6 @@ // Copyright 2017-2018 @polkadot/app-addresses authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow import { translate } from 'react-i18next'; diff --git a/packages/app-explorer/package.json b/packages/app-explorer/package.json index a889a57804..444f1dbb7d 100644 --- a/packages/app-explorer/package.json +++ b/packages/app-explorer/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/app-explorer", - "version": "0.17.15", + "version": "0.18.0", "main": "index.js", "repository": "https://github.com/polkadot-js/apps.git", "author": "Jaco Greeff ", @@ -15,10 +15,10 @@ "test": "jest --coverage" }, "dependencies": { - "@babel/runtime": "^7.0.0-beta.47", - "@polkadot/primitives-codec": "^0.17.24", - "@polkadot/primitives-json": "^0.17.24", - "@polkadot/ui-app": "^0.17.15", - "@polkadot/util-crypto": "^0.22.9" + "@babel/runtime": "^7.0.0-beta.51", + "@polkadot/primitives-codec": "^0.19.5", + "@polkadot/primitives-json": "^0.19.5", + "@polkadot/ui-app": "^0.18.0", + "@polkadot/util-crypto": "^0.24.6" } } diff --git a/packages/app-explorer/src/BestHash.js b/packages/app-explorer/src/BestHash.tsx similarity index 64% rename from packages/app-explorer/src/BestHash.js rename to packages/app-explorer/src/BestHash.tsx index 4fb7516199..0683d361bd 100644 --- a/packages/app-explorer/src/BestHash.js +++ b/packages/app-explorer/src/BestHash.tsx @@ -1,19 +1,19 @@ // Copyright 2017-2018 @polkadot/app-explorer authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { Header } from '@polkadot/primitives/header'; +import { Header } from '@polkadot/primitives/header'; import headerHash from '@polkadot/primitives-codec/header/hash'; import withApiDiv from '@polkadot/ui-react-rx/with/apiDiv'; import u8aToHex from '@polkadot/util/u8a/toHex'; -export default withApiDiv({ name: 'newHead', section: 'chain' })( - (value?: Header): ?string => { - return value +const Component: React.ComponentType = withApiDiv({ name: 'newHead', section: 'chain' })( + (value?: Header): string | undefined => + value ? u8aToHex(headerHash(value), 64) - : value; - }, + : value, { className: 'explorer--BestHash' } ); + +export default Component; diff --git a/packages/app-explorer/src/BlockHeader/index.js b/packages/app-explorer/src/BlockHeader/index.tsx similarity index 89% rename from packages/app-explorer/src/BlockHeader/index.js rename to packages/app-explorer/src/BlockHeader/index.tsx index 017bc347bd..83806b2d9d 100644 --- a/packages/app-explorer/src/BlockHeader/index.js +++ b/packages/app-explorer/src/BlockHeader/index.tsx @@ -1,10 +1,9 @@ // Copyright 2017-2018 @polkadot/app-explorer authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { Header } from '@polkadot/primitives/header'; -import type { I18nProps } from '@polkadot/ui-app/types'; +import { Header } from '@polkadot/primitives/header'; +import { I18nProps } from '@polkadot/ui-app/types'; import './BlockHeader.css'; @@ -21,7 +20,7 @@ type Props = I18nProps & { value?: Header }; -function BlockHeader ({ className, value, style }: Props): React$Node { +function BlockHeader ({ className, value, style }: Props) { if (!value) { return null; } diff --git a/packages/app-explorer/src/BlockHeaders.js b/packages/app-explorer/src/BlockHeaders.tsx similarity index 86% rename from packages/app-explorer/src/BlockHeaders.js rename to packages/app-explorer/src/BlockHeaders.tsx index 6dc4a91e98..2102fa889d 100644 --- a/packages/app-explorer/src/BlockHeaders.js +++ b/packages/app-explorer/src/BlockHeaders.tsx @@ -1,9 +1,8 @@ // Copyright 2017-2018 @polkadot/app-explorer authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { Header } from '@polkadot/primitives/header'; +import { Header } from '@polkadot/primitives/header'; import React from 'react'; @@ -42,13 +41,12 @@ const apiOptions = { }; export default withApiDiv(apiMethod, apiOptions)( - (value?: Array
= []): Array => { - return value.map((value) => ( + (value: Array
= []) => + value.map((value) => ( - )); - }, + )), { className: 'explorer--BlockHeaders' } ); diff --git a/packages/app-explorer/src/index.js b/packages/app-explorer/src/index.tsx similarity index 86% rename from packages/app-explorer/src/index.js rename to packages/app-explorer/src/index.tsx index 4c7a2d5571..1e31f0b391 100644 --- a/packages/app-explorer/src/index.js +++ b/packages/app-explorer/src/index.tsx @@ -1,9 +1,8 @@ // Copyright 2017-2018 @polkadot/app-explorer authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { I18nProps } from '@polkadot/ui-app/types'; +import { I18nProps } from '@polkadot/ui-app/types'; import './index.css'; @@ -18,7 +17,7 @@ import translate from './translate'; type Props = I18nProps & {}; -function ExplorerApp ({ className, style, t }: Props): React$Node { +function ExplorerApp ({ className, style, t }: Props) { return (
", @@ -15,10 +15,10 @@ "test": "jest --coverage" }, "dependencies": { - "@babel/runtime": "^7.0.0-beta.47", - "@polkadot/extrinsics-codec": "^0.17.24", - "@polkadot/ui-app": "^0.17.15", - "@polkadot/ui-signer": "^0.17.15", + "@babel/runtime": "^7.0.0-beta.51", + "@polkadot/extrinsics-codec": "^0.19.5", + "@polkadot/ui-app": "^0.18.0", + "@polkadot/ui-signer": "^0.18.0", "react-dropzone": "^4.2.9" } } diff --git a/packages/app-extrinsics/src/Account.js b/packages/app-extrinsics/src/Account.tsx similarity index 86% rename from packages/app-extrinsics/src/Account.js rename to packages/app-extrinsics/src/Account.tsx index 0613c8cb21..9b69ba9e05 100644 --- a/packages/app-extrinsics/src/Account.js +++ b/packages/app-extrinsics/src/Account.tsx @@ -1,10 +1,9 @@ // Copyright 2017-2018 @polkadot/app-extrinsics authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { KeyringOption$Type } from '@polkadot/ui-keyring/types'; -import type { I18nProps } from '@polkadot/ui-app/types'; +import { KeyringOption$Type } from '@polkadot/ui-keyring/types'; +import { I18nProps } from '@polkadot/ui-app/types'; import React from 'react'; @@ -17,6 +16,7 @@ import translate from './translate'; type Props = I18nProps & { defaultValue?: Uint8Array, + isDisabled?: boolean, isError?: boolean, isInput?: boolean, label: string, @@ -40,8 +40,8 @@ class Account extends React.PureComponent { }; } - render (): React$Node { - const { className, defaultValue, isError, isInput, label, style, t, type, withLabel } = this.props; + render () { + const { className, defaultValue, isDisabled, isError, isInput, label, style, t, type, withLabel } = this.props; const { publicKey } = this.state; return ( @@ -52,6 +52,7 @@ class Account extends React.PureComponent {
void + onChange: (encoded: EncodedMessage) => void, + withLabel?: boolean }; type State = { @@ -46,8 +47,8 @@ class Extrinsic extends React.PureComponent { }; } - render (): React$Node { - const { className, defaultValue, isError, isPrivate, labelMethod, labelSection, style } = this.props; + render () { + const { className, defaultValue, isDisabled, isError, isPrivate, labelMethod, labelSection, style, withLabel } = this.props; const { extrinsic } = this.state; return ( @@ -57,11 +58,13 @@ class Extrinsic extends React.PureComponent { > { ); } - nextState (newState: $Shape): void { + nextState (newState: State): void { this.setState(newState, () => { const { apiSupport, onChange } = this.props; const { extrinsic, values } = this.state; @@ -88,7 +91,7 @@ class Extrinsic extends React.PureComponent { : new Uint8Array([]); onChange({ - extrinsic, + // extrinsic, isValid, values: [value] }); @@ -96,11 +99,11 @@ class Extrinsic extends React.PureComponent { } onChangeExtrinsic = (extrinsic: Extrinsic$Method): void => { - this.nextState({ extrinsic }); + this.nextState({ extrinsic } as State); }; onChangeValues = (values: Array): void => { - this.nextState({ values }); + this.nextState({ values } as State); } } diff --git a/packages/app-extrinsics/src/Nonce.js b/packages/app-extrinsics/src/Nonce.tsx similarity index 87% rename from packages/app-extrinsics/src/Nonce.js rename to packages/app-extrinsics/src/Nonce.tsx index 03969347a8..b93f59107d 100644 --- a/packages/app-extrinsics/src/Nonce.js +++ b/packages/app-extrinsics/src/Nonce.tsx @@ -1,10 +1,9 @@ // Copyright 2017-2018 @polkadot/app-extrinsics authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type BN from 'bn.js'; -import type { BareProps } from '@polkadot/ui-app/types'; +import BN from 'bn.js'; +import { BareProps } from '@polkadot/ui-app/types'; import React from 'react'; @@ -18,7 +17,7 @@ type Props = BareProps & { value?: Uint8Array }; -export default function Nonce ({ className, label, style, onChange, value }: Props): React$Node { +export default function Nonce ({ className, label, style, onChange, value }: Props) { return (
{ - render (): React$Node { + render () { const { className, defaultValue: { value }, isDisabled, isError, label, style, withLabel } = this.props; - // flowlint-next-line unclear-type:off - const defaultValue = ((value: any): Uint8Array); + const defaultValue = (value as Uint8Array); return ( { ); } - onChange = (value?: Uint8Array): void => { + onChange = (publicKey?: Uint8Array): void => { const { onChange } = this.props; onChange({ - isValid: !!value && value.length === 32, - value + isValid: !!publicKey && publicKey.length === 32, + value: publicKey }); } } diff --git a/packages/app-extrinsics/src/Params/Call.js b/packages/app-extrinsics/src/Params/Call.tsx similarity index 77% rename from packages/app-extrinsics/src/Params/Call.js rename to packages/app-extrinsics/src/Params/Call.tsx index 20d547de17..030417a7e1 100644 --- a/packages/app-extrinsics/src/Params/Call.js +++ b/packages/app-extrinsics/src/Params/Call.tsx @@ -1,9 +1,8 @@ // Copyright 2017-2018 @polkadot/app-extrinsics authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { Props } from '@polkadot/ui-app/Params/types'; +import { Props } from '@polkadot/ui-app/Params/types'; import React from 'react'; @@ -11,9 +10,10 @@ import extrinsics from '@polkadot/extrinsics'; import Extrinsic from './Extrinsic'; -const defaultValue = extrinsics.staking.public.transfer; +// @ts-ignore checking? +const defaultValue = extrinsics.get('staking').public.transfer; -export default function Call ({ className, isDisabled, isError, label, onChange, style, withLabel }: Props): React$Node { +export default function Call ({ className, isDisabled, isError, label, onChange, style, withLabel }: Props) { return ( { - render (): React$Node { + render () { const { className, defaultValue, isDisabled, isError, isPrivate, label, style, t, withLabel } = this.props; return ( @@ -58,8 +57,7 @@ class Extrinsic extends React.PureComponent { onChange({ isValid, - // flowlint-next-line unclear-type:off - value: ((values[0]: any): Uint8Array) + value: (values[0] as Uint8Array) }); } } diff --git a/packages/app-extrinsics/src/Params/Proposal.js b/packages/app-extrinsics/src/Params/Proposal.tsx similarity index 76% rename from packages/app-extrinsics/src/Params/Proposal.js rename to packages/app-extrinsics/src/Params/Proposal.tsx index fadb83dd84..08fa6a1428 100644 --- a/packages/app-extrinsics/src/Params/Proposal.js +++ b/packages/app-extrinsics/src/Params/Proposal.tsx @@ -1,9 +1,8 @@ // Copyright 2017-2018 @polkadot/app-extrinsics authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { Props } from '@polkadot/ui-app/Params/types'; +import { Props } from '@polkadot/ui-app/Params/types'; import React from 'react'; @@ -11,9 +10,10 @@ import extrinsics from '@polkadot/extrinsics'; import Extrinsic from './Extrinsic'; -const defaultValue = extrinsics.consensus.private.setCode; +// @ts-ignore check? +const defaultValue = extrinsics.get('consensus').private.setCode; -export default function Proposal ({ className, isDisabled, isError, label, onChange, style, withLabel }: Props): React$Node { +export default function Proposal ({ className, isDisabled, isError, label, onChange, style, withLabel }: Props) { return ( = { +const components: ComponentMap = { 'AccountId': Account, 'Call': Call, 'Proposal': Proposal diff --git a/packages/app-extrinsics/src/Selection.js b/packages/app-extrinsics/src/Selection.tsx similarity index 84% rename from packages/app-extrinsics/src/Selection.js rename to packages/app-extrinsics/src/Selection.tsx index c16b81c992..e2fa0e8c98 100644 --- a/packages/app-extrinsics/src/Selection.js +++ b/packages/app-extrinsics/src/Selection.tsx @@ -1,11 +1,10 @@ // Copyright 2017-2018 @polkadot/app-extrinsics authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type BN from 'bn.js'; -import type { I18nProps } from '@polkadot/ui-app/types'; -import type { EncodedMessage, QueueTx$MessageAdd } from '@polkadot/ui-signer/types'; +import BN from 'bn.js'; +import { I18nProps } from '@polkadot/ui-app/types'; +import { EncodedMessage, QueueTx$MessageAdd } from '@polkadot/ui-signer/types'; import React from 'react'; @@ -30,13 +29,15 @@ type State = { publicKey: Uint8Array }; -const defaultExtrinsic = extrinsics.staking.public.transfer; -const defaultRpc = rpc.author.public.submitExtrinsic; +// @ts-ignore check? +const defaultExtrinsic = extrinsics.get('staking').public.transfer; +// @ts-ignore check? +const defaultRpc = rpc.get('author').public.submitExtrinsic; class Selection extends React.PureComponent { - state: State = ({ + state: State = { isValid: false - }: $Shape); + } as State; render () { const { className, style, t } = this.props; @@ -83,7 +84,7 @@ class Selection extends React.PureComponent { ); } - nextState (newState: $Shape): void { + nextState (newState: State): void { this.setState( (prevState: State): State => { const { encoded = prevState.encoded, nonce = prevState.nonce, publicKey = prevState.publicKey } = newState; @@ -105,15 +106,15 @@ class Selection extends React.PureComponent { } onChangeMessage = (encoded: EncodedMessage): void => { - this.nextState({ encoded }); + this.nextState({ encoded } as State); } onChangeNonce = (nonce: BN): void => { - this.nextState({ nonce }); + this.nextState({ nonce } as State); } onChangeSender = (publicKey: Uint8Array): void => { - this.nextState({ publicKey }); + this.nextState({ publicKey } as State); } onQueue = (): void => { diff --git a/packages/app-extrinsics/src/index.js b/packages/app-extrinsics/src/index.tsx similarity index 67% rename from packages/app-extrinsics/src/index.js rename to packages/app-extrinsics/src/index.tsx index b82ee53108..056efa749b 100644 --- a/packages/app-extrinsics/src/index.js +++ b/packages/app-extrinsics/src/index.tsx @@ -1,33 +1,32 @@ // Copyright 2017-2018 @polkadot/app-extrinsics authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { BareProps } from '@polkadot/ui-app/types'; -import type { QueueProps } from '@polkadot/ui-signer/types'; +import { BareProps } from '@polkadot/ui-app/types'; +import { QueueProps } from '@polkadot/ui-signer/types'; import './index.css'; import React from 'react'; import classes from '@polkadot/ui-app/util/classes'; -import Signer from '@polkadot/ui-signer'; +import { QueueConsumer } from '@polkadot/ui-signer/Context'; import Selection from './Selection'; type Props = BareProps; -export default function ExtrinsicsApp ({ className, style }: Props): React$Node { +export default function ExtrinsicsApp ({ className, style }: Props) { return (
- - {({ queueAdd }: QueueProps = {}) => ( + + {({ queueAdd }: QueueProps) => ( )} - +
); } diff --git a/packages/app-extrinsics/src/translate.js b/packages/app-extrinsics/src/translate.ts similarity index 96% rename from packages/app-extrinsics/src/translate.js rename to packages/app-extrinsics/src/translate.ts index e679c59e44..2399105d04 100644 --- a/packages/app-extrinsics/src/translate.js +++ b/packages/app-extrinsics/src/translate.ts @@ -1,7 +1,6 @@ // Copyright 2017-2018 @polkadot/app-extrinsics authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow import { translate } from 'react-i18next'; diff --git a/packages/app-rpc/package.json b/packages/app-rpc/package.json index 3c6b998f4e..5de9585649 100644 --- a/packages/app-rpc/package.json +++ b/packages/app-rpc/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/app-rpc", - "version": "0.17.15", + "version": "0.18.0", "main": "index.js", "repository": "https://github.com/polkadot-js/apps.git", "author": "Jaco Greeff ", @@ -15,9 +15,9 @@ "test": "jest --coverage" }, "dependencies": { - "@babel/runtime": "^7.0.0-beta.47", - "@polkadot/ui-app": "^0.17.15", - "@polkadot/ui-keyring": "^0.17.15", - "@polkadot/ui-signer": "^0.17.15" + "@babel/runtime": "^7.0.0-beta.51", + "@polkadot/ui-app": "^0.18.0", + "@polkadot/ui-keyring": "^0.18.0", + "@polkadot/ui-signer": "^0.18.0" } } diff --git a/packages/app-rpc/src/Account.js b/packages/app-rpc/src/Account.tsx similarity index 90% rename from packages/app-rpc/src/Account.js rename to packages/app-rpc/src/Account.tsx index f4d641638d..e6b2ecc97a 100644 --- a/packages/app-rpc/src/Account.js +++ b/packages/app-rpc/src/Account.tsx @@ -1,9 +1,8 @@ // Copyright 2017-2018 @polkadot/app-rpc authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { I18nProps } from '@polkadot/ui-app/types'; +import { I18nProps } from '@polkadot/ui-app/types'; import BN from 'bn.js'; import React from 'react'; @@ -16,14 +15,14 @@ import Nonce from '@polkadot/ui-react-rx/Nonce'; import translate from './translate'; type Props = I18nProps & { - defaultValue?: Uint8Array, + defaultValue?: Uint8Array | null, isError?: boolean, - onChange: (publicKey?: Uint8Array, nonce: BN) => void + onChange: (publicKey: Uint8Array | undefined | null, nonce: BN) => void }; type State = { nonce: BN, - publicKey?: Uint8Array + publicKey?: Uint8Array | null }; class Account extends React.PureComponent { @@ -38,7 +37,7 @@ class Account extends React.PureComponent { }; } - render (): React$Node { + render () { const { className, defaultValue, isError, style, t } = this.props; return ( @@ -63,7 +62,7 @@ class Account extends React.PureComponent { ); } - renderNonce (): React$Node { + renderNonce () { const { t } = this.props; const { publicKey } = this.state; diff --git a/packages/app-rpc/src/Results.js b/packages/app-rpc/src/Results.tsx similarity index 88% rename from packages/app-rpc/src/Results.js rename to packages/app-rpc/src/Results.tsx index 0c2b701977..32bb449bdb 100644 --- a/packages/app-rpc/src/Results.js +++ b/packages/app-rpc/src/Results.tsx @@ -1,10 +1,9 @@ // Copyright 2017-2018 @polkadot/app-rpc authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { BareProps } from '@polkadot/ui-app/types'; -import type { QueueTx } from '@polkadot/ui-signer/types'; +import { BareProps } from '@polkadot/ui-app/types'; +import { QueueTx } from '@polkadot/ui-signer/types'; import React from 'react'; @@ -18,7 +17,7 @@ type Props = BareProps & { queue: Array }; -export default function Results ({ className, queue = [], style }: Props): React$Node { +export default function Results ({ className, queue = [], style }: Props) { const filtered = queue .filter(({ error, result }) => !isUndefined(error) || !isUndefined(result) diff --git a/packages/app-rpc/src/Selection.js b/packages/app-rpc/src/Selection.tsx similarity index 82% rename from packages/app-rpc/src/Selection.js rename to packages/app-rpc/src/Selection.tsx index f4bbb3fc4a..fa9ca1e374 100644 --- a/packages/app-rpc/src/Selection.js +++ b/packages/app-rpc/src/Selection.tsx @@ -1,12 +1,11 @@ // Copyright 2017-2018 @polkadot/app-rpc authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { Interface$Method } from '@polkadot/jsonrpc/types'; -import type { RawParam } from '@polkadot/ui-app/Params/types'; -import type { I18nProps } from '@polkadot/ui-app/types'; -import type { QueueTx$MessageAdd } from '@polkadot/ui-signer/types'; +import { Interface$Method } from '@polkadot/jsonrpc/types'; +import { RawParam } from '@polkadot/ui-app/Params/types'; +import { I18nProps } from '@polkadot/ui-app/types'; +import { QueueTx$MessageAdd } from '@polkadot/ui-signer/types'; import './index.css'; @@ -35,7 +34,8 @@ type State = { values: Array } -const defaultMethod = rpc.author.public.submitExtrinsic; +// @ts-ignore check? +const defaultMethod = rpc.get('author').public.submitExtrinsic; class Selection extends React.PureComponent { state: State = { @@ -46,7 +46,7 @@ class Selection extends React.PureComponent { values: [] }; - render (): React$Node { + render () { const { className, style, t } = this.props; const { isValid, rpc } = this.state; @@ -78,7 +78,7 @@ class Selection extends React.PureComponent { ); } - renderAccount (): React$Node { + renderAccount () { const { rpc: { isSigned = false }, publicKey } = this.state; if (!isSigned) { @@ -93,7 +93,7 @@ class Selection extends React.PureComponent { ); } - nextState (newState: $Shape): void { + nextState (newState: State): void { this.setState( (prevState: State): State => { const { rpc = prevState.rpc, nonce = prevState.nonce, publicKey = prevState.publicKey, values = prevState.values } = newState; @@ -112,16 +112,16 @@ class Selection extends React.PureComponent { ); } - onChangeAccount = (publicKey?: Uint8Array, nonce: BN): void => { - this.nextState({ nonce, publicKey }); + onChangeAccount = (publicKey: Uint8Array | undefined | null, nonce: BN): void => { + this.nextState({ nonce, publicKey } as State); } onChangeMethod = (rpc: Interface$Method): void => { - this.nextState({ rpc }); + this.nextState({ rpc } as State); } onChangeValues = (values: Array): void => { - this.nextState({ values }); + this.nextState({ values } as State); } onSubmit = (): void => { diff --git a/packages/app-rpc/src/index.js b/packages/app-rpc/src/index.tsx similarity index 65% rename from packages/app-rpc/src/index.js rename to packages/app-rpc/src/index.tsx index 5d9af28362..6d0c92d67e 100644 --- a/packages/app-rpc/src/index.js +++ b/packages/app-rpc/src/index.tsx @@ -1,31 +1,30 @@ // Copyright 2017-2018 @polkadot/app-rpc authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { BareProps } from '@polkadot/ui-app/types'; -import type { QueueProps } from '@polkadot/ui-signer/types'; +import { BareProps } from '@polkadot/ui-app/types'; +import { QueueProps } from '@polkadot/ui-signer/types'; import './index.css'; import React from 'react'; import classes from '@polkadot/ui-app/util/classes'; -import Signer from '@polkadot/ui-signer'; +import { QueueConsumer } from '@polkadot/ui-signer/Context'; import Results from './Results'; import Selection from './Selection'; type Props = BareProps & {}; -export default function RpcApp ({ className, style }: Props): React$Node { +export default function RpcApp ({ className, style }: Props) { return (
- - {({ queue, queueAdd }: QueueProps = {}) => [ + + {({ queue, queueAdd }: QueueProps) => [ ]} - +
); } diff --git a/packages/app-rpc/src/resultToText.js b/packages/app-rpc/src/resultToText.ts similarity index 76% rename from packages/app-rpc/src/resultToText.js rename to packages/app-rpc/src/resultToText.ts index dd6d5c3208..0a9d5ec3f1 100644 --- a/packages/app-rpc/src/resultToText.js +++ b/packages/app-rpc/src/resultToText.ts @@ -1,7 +1,6 @@ // Copyright 2017-2018 @polkadot/app-rpc authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow import bnToHex from '@polkadot/util/bn/toHex'; import u8aToHex from '@polkadot/util/u8a/toHex'; @@ -9,18 +8,16 @@ import isBn from '@polkadot/util/is/bn'; import isObject from '@polkadot/util/is/object'; import isU8a from '@polkadot/util/is/u8a'; -function resultToText (result: mixed): mixed { +function resultToText (result: any): any { if (result === null || result === undefined) { return 'null'; } if (isU8a(result)) { - // $FlowFixMe type has been determined return u8aToHex(result); } if (isBn(result)) { - // $FlowFixMe type has been determined return bnToHex(result); } @@ -33,15 +30,13 @@ function resultToText (result: mixed): mixed { if (isObject(result)) { return JSON .stringify( - // $FlowFixMe type has been determined Object .keys(result) .reduce((map, key) => { - // $FlowFixMe type has been determined - map[key] = resultToText(result[key]); + map[key] = resultToText((result as { [index: string]: string })[key]); return map; - }, {}) + }, ({} as { [index: string]: string })) ) .replace(/\\"/g, '"') .replace(/":"/g, '": "'); diff --git a/packages/app-rpc/src/translate.js b/packages/app-rpc/src/translate.ts similarity index 96% rename from packages/app-rpc/src/translate.js rename to packages/app-rpc/src/translate.ts index 27564138f8..79c52f8101 100644 --- a/packages/app-rpc/src/translate.js +++ b/packages/app-rpc/src/translate.ts @@ -1,7 +1,6 @@ // Copyright 2017-2018 @polkadot/app-rpc authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow import { translate } from 'react-i18next'; diff --git a/packages/app-storage/package.json b/packages/app-storage/package.json index 3776c2d427..8ae38c40a8 100644 --- a/packages/app-storage/package.json +++ b/packages/app-storage/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/app-storage", - "version": "0.17.15", + "version": "0.18.0", "main": "index.js", "repository": "https://github.com/polkadot-js/apps.git", "author": "Jaco Greeff ", @@ -15,7 +15,7 @@ "test": "jest --coverage" }, "dependencies": { - "@babel/runtime": "^7.0.0-beta.47", - "@polkadot/ui-app": "^0.17.15" + "@babel/runtime": "^7.0.0-beta.51", + "@polkadot/ui-app": "^0.18.0" } } diff --git a/packages/app-storage/src/Queries.js b/packages/app-storage/src/Queries.tsx similarity index 80% rename from packages/app-storage/src/Queries.js rename to packages/app-storage/src/Queries.tsx index f46f61fef4..864ddd9781 100644 --- a/packages/app-storage/src/Queries.js +++ b/packages/app-storage/src/Queries.tsx @@ -1,10 +1,9 @@ // Copyright 2017-2018 @polkadot/app-storage authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { I18nProps } from '@polkadot/ui-app/types'; -import type { StorageQuery } from './types'; +import { I18nProps } from '@polkadot/ui-app/types'; +import { StorageQuery } from './types'; import React from 'react'; @@ -18,7 +17,7 @@ type Props = I18nProps & { value?: Array }; -function Queries ({ className, onRemove, style, value }: Props): React$Node { +function Queries ({ className, onRemove, style, value }: Props) { if (!value || !value.length) { return null; } diff --git a/packages/app-storage/src/Query.js b/packages/app-storage/src/Query.tsx similarity index 78% rename from packages/app-storage/src/Query.js rename to packages/app-storage/src/Query.tsx index 696d9b9e06..1f46c972d2 100644 --- a/packages/app-storage/src/Query.js +++ b/packages/app-storage/src/Query.tsx @@ -1,10 +1,10 @@ // Copyright 2017-2018 @polkadot/app-storage authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { I18nProps } from '@polkadot/ui-app/types'; -import type { StorageQuery } from './types'; +import { Storage$Key$Value } from '@polkadot/storage/types'; +import { I18nProps } from '@polkadot/ui-app/types'; +import { StorageQuery } from './types'; import React from 'react'; @@ -25,22 +25,24 @@ type Props = I18nProps & { type ComponentProps = {}; type State = { - inputs: Array, - Component: React$ComponentType; + inputs: Array, // node? + Component: React.ComponentType; }; -const cache = []; +const cache: Array> = []; class Query extends React.PureComponent { - state: State = ({}: $Shape); + state: State = {} as State; - static getCachedComponent ({ id, key, params }: StorageQuery): React$ComponentType { + static getCachedComponent ({ id, key, params }: StorageQuery): React.ComponentType { if (!cache[id]) { - const values = params.map(({ value }) => value); + const values: Array = params.map(({ value }) => + // FIXME not 100% convinced, arrays could be an issue? (Plus, if we have to cast, something just _seems_ off) + value as Storage$Key$Value + ); - // $FlowFixMe we SHOULD be transforming these before passing cache[id] = withStorageDiv(key, { params: values })( - (value) => + (value: any) => valueToText(key.type, value), { className: 'ui--output' } ); @@ -64,7 +66,7 @@ class Query extends React.PureComponent { }; } - render (): React$Node { + render () { const { className, style, value: { key } } = this.props; const { Component, inputs } = this.state; diff --git a/packages/app-storage/src/Selection.js b/packages/app-storage/src/Selection.tsx similarity index 84% rename from packages/app-storage/src/Selection.js rename to packages/app-storage/src/Selection.tsx index 93d7bc3794..25baab4735 100644 --- a/packages/app-storage/src/Selection.js +++ b/packages/app-storage/src/Selection.tsx @@ -1,12 +1,11 @@ // Copyright 2017-2018 @polkadot/app-storage authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { Storage$Key } from '@polkadot/storage/types'; -import type { I18nProps } from '@polkadot/ui-app/types'; -import type { RawParams } from '@polkadot/ui-app/Params/types'; -import type { StorageQuery } from './types'; +import { Storage$Key } from '@polkadot/storage/types'; +import { I18nProps } from '@polkadot/ui-app/types'; +import { RawParams } from '@polkadot/ui-app/Params/types'; +import { StorageQuery } from './types'; import React from 'react'; @@ -30,7 +29,8 @@ type State = { params: RawParams }; -const defaultValue = storage.timestamp.public.current; +// @ts-ignore check? +const defaultValue = storage.get('timestamp').public.current; let id = -1; class Selection extends React.PureComponent { @@ -40,7 +40,7 @@ class Selection extends React.PureComponent { params: [] }; - render (): React$Node { + render () { const { className, style, t } = this.props; const { isValid, key } = this.state; @@ -74,7 +74,7 @@ class Selection extends React.PureComponent { ); } - nextState (newState: $Shape): void { + nextState (newState: State): void { this.setState( (prevState: State) => { const { key = prevState.key, params = prevState.params } = newState; @@ -107,11 +107,11 @@ class Selection extends React.PureComponent { } onChangeKey = (key: Storage$Key): void => { - this.nextState({ key }); + this.nextState({ key } as State); } - onChangeParams = (params?: RawParams = []): void => { - this.nextState({ params }); + onChangeParams = (params: RawParams = []): void => { + this.nextState({ params } as State); } } diff --git a/packages/app-storage/src/index.js b/packages/app-storage/src/index.tsx similarity index 90% rename from packages/app-storage/src/index.js rename to packages/app-storage/src/index.tsx index 98b5410648..403346253d 100644 --- a/packages/app-storage/src/index.js +++ b/packages/app-storage/src/index.tsx @@ -1,10 +1,9 @@ // Copyright 2017-2018 @polkadot/app-storage authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { I18nProps } from '@polkadot/ui-app/types'; -import type { StorageQuery } from './types'; +import { I18nProps } from '@polkadot/ui-app/types'; +import { StorageQuery } from './types'; import './index.css'; @@ -27,7 +26,7 @@ class StorageApp extends React.PureComponent { queue: [] }; - render (): React$Node { + render () { const { className, style } = this.props; const { queue } = this.state; diff --git a/packages/app-storage/src/translate.js b/packages/app-storage/src/translate.ts similarity index 96% rename from packages/app-storage/src/translate.js rename to packages/app-storage/src/translate.ts index 2a91f254f0..9ce164807c 100644 --- a/packages/app-storage/src/translate.js +++ b/packages/app-storage/src/translate.ts @@ -1,7 +1,6 @@ // Copyright 2017-2018 @polkadot/app-storage authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow import { translate } from 'react-i18next'; diff --git a/packages/app-storage/src/types.js b/packages/app-storage/src/types.d.ts similarity index 67% rename from packages/app-storage/src/types.js rename to packages/app-storage/src/types.d.ts index c7005b18cd..152d57e0d1 100644 --- a/packages/app-storage/src/types.js +++ b/packages/app-storage/src/types.d.ts @@ -1,10 +1,9 @@ // Copyright 2017-2018 @polkadot/app-storage authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { Storage$Key } from '@polkadot/storage/types'; -import type { RawParams } from '@polkadot/ui-app/Params/types'; +import { Storage$Key } from '@polkadot/storage/types'; +import { RawParams } from '@polkadot/ui-app/Params/types'; export type StorageQuery = { id: number, diff --git a/packages/app-toolbox/package.json b/packages/app-toolbox/package.json index c091bed0ad..96cd0c6016 100644 --- a/packages/app-toolbox/package.json +++ b/packages/app-toolbox/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/app-toolbox", - "version": "0.17.15", + "version": "0.18.0", "main": "index.js", "repository": "https://github.com/polkadot-js/apps.git", "author": "Jaco Greeff ", @@ -15,8 +15,8 @@ "test": "jest --coverage" }, "dependencies": { - "@babel/runtime": "^7.0.0-beta.47", - "@polkadot/ui-app": "^0.17.15", - "@polkadot/ui-keyring": "^0.17.15" + "@babel/runtime": "^7.0.0-beta.51", + "@polkadot/ui-app": "^0.18.0", + "@polkadot/ui-keyring": "^0.18.0" } } diff --git a/packages/app-toolbox/src/Hash.js b/packages/app-toolbox/src/Hash.tsx similarity index 93% rename from packages/app-toolbox/src/Hash.js rename to packages/app-toolbox/src/Hash.tsx index 88f60f4df1..39c58d435f 100644 --- a/packages/app-toolbox/src/Hash.js +++ b/packages/app-toolbox/src/Hash.tsx @@ -1,9 +1,8 @@ // Copyright 2017-2018 @polkadot/app-toolbox authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { I18nProps as Props } from '@polkadot/ui-app/types'; +import { I18nProps as Props } from '@polkadot/ui-app/types'; import React from 'react'; @@ -31,7 +30,7 @@ class Hash extends React.PureComponent { isHexData: false }; - render (): React$Node { + render () { const { className, style } = this.props; return ( @@ -45,7 +44,7 @@ class Hash extends React.PureComponent { ); } - renderInput (): React$Node { + renderInput () { const { t } = this.props; const { data, isHexData } = this.state; @@ -78,7 +77,7 @@ class Hash extends React.PureComponent { ); } - renderOutput (): React$Node { + renderOutput () { const { t } = this.props; const { hash } = this.state; diff --git a/packages/app-toolbox/src/Sign.js b/packages/app-toolbox/src/Sign.tsx similarity index 90% rename from packages/app-toolbox/src/Sign.js rename to packages/app-toolbox/src/Sign.tsx index 1131cc87d0..4df7bb77d7 100644 --- a/packages/app-toolbox/src/Sign.js +++ b/packages/app-toolbox/src/Sign.tsx @@ -1,10 +1,9 @@ // Copyright 2017-2018 @polkadot/app-toolbox authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { I18nProps as Props } from '@polkadot/ui-app/types'; -import type { KeyringPair } from '@polkadot/util-keyring/types'; +import { I18nProps as Props } from '@polkadot/ui-app/types'; +import { KeyringPair } from '@polkadot/util-keyring/types'; import React from 'react'; @@ -14,7 +13,7 @@ import InputAddress from '@polkadot/ui-app/InputAddress'; import Output from '@polkadot/ui-app/Output'; import Static from '@polkadot/ui-app/Static'; import classes from '@polkadot/ui-app/util/classes'; -import keyring from '@polkadot/ui-keyring'; +import keyring from '@polkadot/ui-keyring/index'; import hexToU8a from '@polkadot/util/hex/toU8a'; import isHex from '@polkadot/util/is/hex'; import u8aFromString from '@polkadot/util/u8a/fromString'; @@ -57,7 +56,7 @@ class Sign extends React.PureComponent { }; } - render (): React$Node { + render () { const { className, style } = this.props; return ( @@ -74,7 +73,7 @@ class Sign extends React.PureComponent { ); } - renderAccount (): React$Node { + renderAccount () { const { t } = this.props; const { defaultValue } = this.state; @@ -94,7 +93,7 @@ class Sign extends React.PureComponent { ); } - renderButtons (): React$Node { + renderButtons () { const { t } = this.props; const { isLocked } = this.state; @@ -115,7 +114,7 @@ class Sign extends React.PureComponent { ); } - renderInput (): React$Node { + renderInput () { const { t } = this.props; const { data, isHexData } = this.state; @@ -148,7 +147,7 @@ class Sign extends React.PureComponent { ); } - renderSignature (): React$Node { + renderSignature () { const { t } = this.props; const { signature } = this.state; @@ -167,7 +166,7 @@ class Sign extends React.PureComponent { ); } - renderUnlock (): React$Node { + renderUnlock () { const { currentPair, isUnlockVisible } = this.state; if (!isUnlockVisible) { @@ -182,9 +181,9 @@ class Sign extends React.PureComponent { ); } - nextState = (newState: $Shape): void => { + nextState = (newState: State): void => { this.setState( - (prevState: State): $Shape => { + (prevState: State): State => { const { currentPair = prevState.currentPair, data = prevState.data, isHexData = prevState.isHexData, isUnlockVisible = prevState.isUnlockVisible } = newState; const isLocked = !currentPair || !currentPair.hasSecretKey(); let signature = ''; @@ -216,19 +215,19 @@ class Sign extends React.PureComponent { this.nextState({ isUnlockVisible: !isUnlockVisible - }); + } as State); } onChangeAccount = (publicKey: Uint8Array): void => { const currentPair = keyring.getPair(publicKey); - this.nextState({ currentPair }); + this.nextState({ currentPair } as State); } onChangeData = (data: string): void => { const isHexData = isHex(data); - this.nextState({ data, isHexData }); + this.nextState({ data, isHexData } as State); } onUnlock = (): void => { diff --git a/packages/app-toolbox/src/Unlock.js b/packages/app-toolbox/src/Unlock.tsx similarity index 89% rename from packages/app-toolbox/src/Unlock.js rename to packages/app-toolbox/src/Unlock.tsx index 54603c77a2..9b6caa438b 100644 --- a/packages/app-toolbox/src/Unlock.js +++ b/packages/app-toolbox/src/Unlock.tsx @@ -1,10 +1,9 @@ // Copyright 2017-2018 @polkadot/app-toolbox authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { I18nProps } from '@polkadot/ui-app/types'; -import type { KeyringPair } from '@polkadot/util-keyring/types'; +import { I18nProps } from '@polkadot/ui-app/types'; +import { KeyringPair } from '@polkadot/util-keyring/types'; import React from 'react'; import { Trans } from 'react-i18next'; @@ -19,12 +18,12 @@ import translate from './translate'; type Props = I18nProps & { onClose: () => void, - pair: KeyringPair + pair: KeyringPair | null }; type UnlockI18n = { key: string, - value: I18Next$Translate$Config + value: any // I18Next$Translate$Config } type State = { @@ -40,15 +39,15 @@ class Unlock extends React.PureComponent { unlockError: null }; - static getDerivedStateFromProps ({ pair }: Props, prevState: State): $Shape { + static getDerivedStateFromProps ({ pair }: Props, prevState: State): State { return { address: pair ? pair.address() : '' - }; + } as State; } - render (): React$Node { + render () { const { className, style, t } = this.props; return ( @@ -73,7 +72,7 @@ class Unlock extends React.PureComponent { ); } - renderActions (): React$Node { + renderActions () { const { t } = this.props; return ( @@ -97,7 +96,7 @@ class Unlock extends React.PureComponent { ); } - renderContent (): React$Node { + renderContent () { const { t } = this.props; const { address, password, unlockError } = this.state; @@ -105,6 +104,7 @@ class Unlock extends React.PureComponent {

+ // @ts-ignore ok, Trans def seems wrong? You are about to unlock your account {address} to allow for the signing of messages. @@ -131,10 +131,10 @@ class Unlock extends React.PureComponent { ]; } - unlockAccount (password?: string): ?UnlockI18n { + unlockAccount (password?: string): UnlockI18n | null { const { pair } = this.props; - if (pair.hasSecretKey()) { + if (!pair || pair.hasSecretKey()) { return null; } diff --git a/packages/app-toolbox/src/Verify.js b/packages/app-toolbox/src/Verify.tsx similarity index 91% rename from packages/app-toolbox/src/Verify.js rename to packages/app-toolbox/src/Verify.tsx index 7c34e252f8..609752ff10 100644 --- a/packages/app-toolbox/src/Verify.js +++ b/packages/app-toolbox/src/Verify.tsx @@ -1,9 +1,8 @@ // Copyright 2017-2018 @polkadot/app-toolbox authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { I18nProps as Props } from '@polkadot/ui-app/types'; +import { I18nProps as Props } from '@polkadot/ui-app/types'; import React from 'react'; @@ -12,7 +11,7 @@ import Input from '@polkadot/ui-app/Input'; import InputAddress from '@polkadot/ui-app/InputAddress'; import Static from '@polkadot/ui-app/Static'; import classes from '@polkadot/ui-app/util/classes'; -import keyring from '@polkadot/ui-keyring'; +import keyring from '@polkadot/ui-keyring/index'; import hexToU8a from '@polkadot/util/hex/toU8a'; import isHex from '@polkadot/util/is/hex'; import u8aFromString from '@polkadot/util/u8a/fromString'; @@ -55,7 +54,7 @@ class Verify extends React.PureComponent { }; } - render (): React$Node { + render () { const { className, style } = this.props; return ( @@ -70,7 +69,7 @@ class Verify extends React.PureComponent { ); } - renderAddress (): React$Node { + renderAddress () { const { t } = this.props; const { defaultPublicKey, isValidAddress } = this.state; @@ -90,7 +89,7 @@ class Verify extends React.PureComponent { ); } - renderInput (): React$Node { + renderInput () { const { t } = this.props; const { data, isHexData } = this.state; @@ -123,7 +122,7 @@ class Verify extends React.PureComponent { ); } - renderSignature (): React$Node { + renderSignature () { const { t } = this.props; const { isValid, isValidSignature, signature } = this.state; @@ -149,7 +148,7 @@ class Verify extends React.PureComponent { ); } - nextState (newState: $Shape): void { + nextState (newState: State): void { this.setState( (prevState: State): State => { const { isHexData = prevState.isHexData, isValidAddress = prevState.isValidAddress, isValidSignature = prevState.isValidSignature, currentPublicKey = prevState.currentPublicKey, data = prevState.data, signature = prevState.signature } = newState; @@ -182,19 +181,19 @@ class Verify extends React.PureComponent { onChangeData = (data: string): void => { const isHexData = isHex(data); - this.nextState({ data, isHexData }); + this.nextState({ data, isHexData } as State); } onChangeSignature = (signature: string): void => { const isValidSignature = isHex(signature) && signature.length === 130; - this.nextState({ signature, isValidSignature }); + this.nextState({ signature, isValidSignature } as State); } onChangeAddress = (currentPublicKey: Uint8Array): void => { const isValidAddress = currentPublicKey && currentPublicKey.length === 32; - this.nextState({ currentPublicKey, isValidAddress }); + this.nextState({ currentPublicKey, isValidAddress } as State); } } diff --git a/packages/app-toolbox/src/index.js b/packages/app-toolbox/src/index.tsx similarity index 92% rename from packages/app-toolbox/src/index.js rename to packages/app-toolbox/src/index.tsx index bfe0e804a0..973d141808 100644 --- a/packages/app-toolbox/src/index.js +++ b/packages/app-toolbox/src/index.tsx @@ -1,9 +1,8 @@ // Copyright 2017-2018 @polkadot/app-toolbox authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { I18nProps } from '@polkadot/ui-app/types'; +import { I18nProps } from '@polkadot/ui-app/types'; import './index.css'; @@ -26,7 +25,7 @@ type State = { } // FIXME React-router would probably be the best route, not home-grown -const Components: { [Actions]: React$ComponentType<{}> } = { +const Components: { [index: string]: React.ComponentType } = { // Actions 'hash': Hash, 'sign': Sign, 'verify': Verify @@ -37,7 +36,7 @@ class ToolboxApp extends React.PureComponent { action: 'hash' }; - render (): React$Node { + render () { const { className, style } = this.props; const { action } = this.state; const Component = Components[action]; @@ -53,7 +52,7 @@ class ToolboxApp extends React.PureComponent { ); } - renderButtons (): React$Node { + renderButtons () { const { t } = this.props; const { action } = this.state; diff --git a/packages/app-toolbox/src/translate.js b/packages/app-toolbox/src/translate.ts similarity index 96% rename from packages/app-toolbox/src/translate.js rename to packages/app-toolbox/src/translate.ts index 3b6d5d2e0a..30cc5857ba 100644 --- a/packages/app-toolbox/src/translate.js +++ b/packages/app-toolbox/src/translate.ts @@ -1,7 +1,6 @@ // Copyright 2017-2018 @polkadot/app-toolbox authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow import { translate } from 'react-i18next'; diff --git a/packages/app-vanitygen/package.json b/packages/app-vanitygen/package.json index 68b070d4e7..7f23fa7e22 100644 --- a/packages/app-vanitygen/package.json +++ b/packages/app-vanitygen/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/app-vanitygen", - "version": "0.17.15", + "version": "0.18.0", "main": "index.js", "repository": "https://github.com/polkadot-js/apps.git", "author": "Jaco Greeff ", @@ -15,8 +15,9 @@ "test": "jest --coverage" }, "dependencies": { - "@babel/runtime": "^7.0.0-beta.47", - "@polkadot/ui-app": "^0.17.15", + "@babel/runtime": "^7.0.0-beta.51", + "@polkadot/ui-app": "^0.18.0", + "@types/yargs": "^11.0.0", "chalk": "^2.4.1", "yargs": "10.1.2" }, diff --git a/packages/app-vanitygen/src/Match.js b/packages/app-vanitygen/src/Match.tsx similarity index 94% rename from packages/app-vanitygen/src/Match.js rename to packages/app-vanitygen/src/Match.tsx index 1d5e5ef107..13577af96d 100644 --- a/packages/app-vanitygen/src/Match.js +++ b/packages/app-vanitygen/src/Match.tsx @@ -1,9 +1,8 @@ // Copyright 2017-2018 @polkadot/app-vanitygen authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { BareProps } from '@polkadot/ui-app/types'; +import { BareProps } from '@polkadot/ui-app/types'; import React from 'react'; @@ -26,7 +25,7 @@ type State = { }; export default class Match extends React.PureComponent { - state: State = ({}: $Shape); + state: State = {} as State; static getDerivedStateFromProps ({ seed }: Props): State { return { @@ -34,7 +33,7 @@ export default class Match extends React.PureComponent { }; } - render (): React$Node { + render () { const { address, className, count, offset, style } = this.props; const { hexSeed } = this.state; diff --git a/packages/app-vanitygen/src/generator/calculate.js b/packages/app-vanitygen/src/generator/calculate.ts similarity index 81% rename from packages/app-vanitygen/src/generator/calculate.js rename to packages/app-vanitygen/src/generator/calculate.ts index 5935e8cabb..40eba3092d 100644 --- a/packages/app-vanitygen/src/generator/calculate.js +++ b/packages/app-vanitygen/src/generator/calculate.ts @@ -1,9 +1,8 @@ // Copyright 2017-2018 @polkadot/app-vanitygen authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { Generator$Calculation, Generator$Options } from './types'; +import { Generator$Calculation, Generator$Options } from './types'; function calculateAt (atOffset: number, test: Array, address: string): Generator$Calculation { return { @@ -18,7 +17,7 @@ function calculateAt (atOffset: number, test: Array, address: string): G }; } -module.exports = function calculate (test: Array, _address: string, { atOffset = -1, withCase = false }: Generator$Options): Generator$Calculation { +export default function calculate (test: Array, _address: string, { atOffset = -1, withCase = false }: Generator$Options): Generator$Calculation { const address = withCase ? _address : _address.toLowerCase(); @@ -44,4 +43,4 @@ module.exports = function calculate (test: Array, _address: string, { at count: bestCount, offset: bestOffset }; -}; +} diff --git a/packages/app-vanitygen/src/generator/cli.js b/packages/app-vanitygen/src/generator/cli.ts similarity index 74% rename from packages/app-vanitygen/src/generator/cli.js rename to packages/app-vanitygen/src/generator/cli.ts index 000ccbb6ff..04dd6c7789 100644 --- a/packages/app-vanitygen/src/generator/cli.js +++ b/packages/app-vanitygen/src/generator/cli.ts @@ -3,13 +3,20 @@ // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -const yargs = require('yargs'); -const chalk = require('chalk'); -const u8aToHex = require('@polkadot/util/u8a/toHex'); +import yargs from 'yargs'; +import chalk from 'chalk'; +import u8aToHex from '@polkadot/util/u8a/toHex'; -const generator = require('./index.js'); -const matchRegex = require('./regex'); -const { pkFromSeed } = require('./sodium'); +import generator from './index'; +import matchRegex from './regex'; +import { pkFromSeed } from './sodium'; + +type Best = { + address: string, + count: number, + offset: number, + seed?: Uint8Array +} const { match, withCase } = yargs .option('match', { @@ -29,8 +36,12 @@ const options = { withCase }; const startAt = Date.now(); -let best = { count: -1 }; -let total = 0; +let best: Best = { + address: '', + count: -1, + offset: 65536 +}; +let total: number = 0; let indicator = -1; if (!matchRegex.test(match)) { @@ -49,7 +60,7 @@ function showProgress () { indicator = 0; } - process.stdout.write(`\r[${INDICATORS[indicator]}] ${total.toString().match(NUMBER_REGEX).join(',')} keys in ${(elapsed).toFixed(2)}s (${(total / elapsed).toFixed(0)} keys/s)`); + process.stdout.write(`\r[${INDICATORS[indicator]}] ${(total.toString().match(NUMBER_REGEX) || []).join(',')} keys in ${(elapsed).toFixed(2)}s (${(total / elapsed).toFixed(0)} keys/s)`); } function showBest () { diff --git a/packages/app-vanitygen/src/generator/generate.js b/packages/app-vanitygen/src/generator/generate.js deleted file mode 100644 index b666056f09..0000000000 --- a/packages/app-vanitygen/src/generator/generate.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017-2018 @polkadot/app-vanitygen authors & contributors -// This software may be modified and distributed under the terms -// of the ISC license. See the LICENSE file for details. -// @flow - -import type { Generator$PkFromSeed, Generator$Match, Generator$Options } from './types'; - -const randomBytes = require('@polkadot/util-crypto/random/asU8a'); -const addressEncode = require('@polkadot/util-keyring/address/encode'); -const pairFromSeed = require('@polkadot/util-crypto/nacl/keypair/fromSeed'); - -const calculate = require('./calculate'); - -const tweetPkFromSeed = (seed: Uint8Array): Uint8Array => - pairFromSeed(seed).publicKey; - -module.exports = function generator (test: Array, options: Generator$Options, pkFromSeed?: Generator$PkFromSeed = tweetPkFromSeed): Generator$Match { - const seed = randomBytes(); - const address = addressEncode(pkFromSeed(seed)); - const { count, offset } = calculate(test, address, options); - - return { - address, - count, - offset, - seed - }; -}; diff --git a/packages/app-vanitygen/src/generator/generate.ts b/packages/app-vanitygen/src/generator/generate.ts new file mode 100644 index 0000000000..c331ed9598 --- /dev/null +++ b/packages/app-vanitygen/src/generator/generate.ts @@ -0,0 +1,27 @@ +// Copyright 2017-2018 @polkadot/app-vanitygen authors & contributors +// This software may be modified and distributed under the terms +// of the ISC license. See the LICENSE file for details. + +import { Generator$PkFromSeed, Generator$Match, Generator$Options } from './types'; + +import randomBytes from '@polkadot/util-crypto/random/asU8a'; +import addressEncode from '@polkadot/util-keyring/address/encode'; +import pairFromSeed from '@polkadot/util-crypto/nacl/keypair/fromSeed'; + +import calculate from './calculate'; + +const tweetPkFromSeed = (seed: Uint8Array): Uint8Array => + pairFromSeed(seed).publicKey; + +export default function generator (test: Array, options: Generator$Options, pkFromSeed: Generator$PkFromSeed = tweetPkFromSeed): Generator$Match { + const seed = randomBytes(); + const address = addressEncode(pkFromSeed(seed)); + const { count, offset } = calculate(test, address, options); + + return { + address, + count, + offset, + seed + }; +} diff --git a/packages/app-vanitygen/src/generator/index.js b/packages/app-vanitygen/src/generator/index.ts similarity index 66% rename from packages/app-vanitygen/src/generator/index.js rename to packages/app-vanitygen/src/generator/index.ts index 054dd9fc81..4137cb67b4 100644 --- a/packages/app-vanitygen/src/generator/index.js +++ b/packages/app-vanitygen/src/generator/index.ts @@ -1,13 +1,12 @@ // Copyright 2017-2018 @polkadot/app-vanitygen authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { Generator$PkFromSeed, Generator$Matches, Generator$Result, Generator$Options } from './types'; +import { Generator$PkFromSeed, Generator$Matches, Generator$Result, Generator$Options } from './types'; -const generate = require('./generate'); +import generate from './generate'; -module.exports = function generator (options: Generator$Options, pkFromSeed?: Generator$PkFromSeed): Generator$Result { +export default function generator (options: Generator$Options, pkFromSeed?: Generator$PkFromSeed): Generator$Result { const { match, runs = 10, withCase = false } = options; const test = withCase ? match.split('') @@ -23,4 +22,4 @@ module.exports = function generator (options: Generator$Options, pkFromSeed?: Ge elapsed: Date.now() - startAt, found }; -}; +} diff --git a/packages/app-vanitygen/src/generator/regex.js b/packages/app-vanitygen/src/generator/regex.ts similarity index 88% rename from packages/app-vanitygen/src/generator/regex.js rename to packages/app-vanitygen/src/generator/regex.ts index 1932c62f96..467a6f4e6f 100644 --- a/packages/app-vanitygen/src/generator/regex.js +++ b/packages/app-vanitygen/src/generator/regex.ts @@ -1,8 +1,7 @@ // Copyright 2017-2018 @polkadot/app-vanitygen authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow const regex = new RegExp('^[1-9A-HJ-NP-Za-km-z]*$', ''); -module.exports = regex; +export default regex; diff --git a/packages/app-vanitygen/src/generator/sodium.js b/packages/app-vanitygen/src/generator/sodium.ts similarity index 72% rename from packages/app-vanitygen/src/generator/sodium.js rename to packages/app-vanitygen/src/generator/sodium.ts index fb5dd6f53b..d7bb315709 100644 --- a/packages/app-vanitygen/src/generator/sodium.js +++ b/packages/app-vanitygen/src/generator/sodium.ts @@ -1,12 +1,13 @@ // Copyright 2017-2018 @polkadot/app-vanitygen authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -const bufferToU8a = require('@polkadot/util/buffer/toU8a'); -const u8aToBuffer = require('@polkadot/util/u8a/toBuffer'); +import bufferToU8a from '@polkadot/util/buffer/toU8a'; +import u8aToBuffer from '@polkadot/util/u8a/toBuffer'; -let pkFromSeed = void 0; +type PkSeedFn = (seed: Uint8Array) => Uint8Array; + +let pkFromSeed: PkSeedFn | undefined; try { const sodium = require('sodium'); @@ -22,6 +23,6 @@ try { console.log(`Using NaCl bindings from 'tweet-nacl' (faster 'sodium' dependency not installed)`); } -module.exports = { +export { pkFromSeed }; diff --git a/packages/app-vanitygen/src/generator/sort.js b/packages/app-vanitygen/src/generator/sort.ts similarity index 81% rename from packages/app-vanitygen/src/generator/sort.js rename to packages/app-vanitygen/src/generator/sort.ts index 724fa261ed..2b9cae38b3 100644 --- a/packages/app-vanitygen/src/generator/sort.js +++ b/packages/app-vanitygen/src/generator/sort.ts @@ -1,9 +1,8 @@ // Copyright 2017-2018 @polkadot/app-vanitygen authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { Generator$Match } from './types'; +import { Generator$Match } from './types'; function numberSort (a: number, b: number): number { if (a > b) { @@ -15,7 +14,7 @@ function numberSort (a: number, b: number): number { return 0; } -module.exports = function sort (a: Generator$Match, b: Generator$Match): number { +export default function sort (a: Generator$Match, b: Generator$Match): number { const countResult = numberSort(a.count, b.count); if (countResult !== 0) { diff --git a/packages/app-vanitygen/src/generator/types.js b/packages/app-vanitygen/src/generator/types.d.ts similarity index 98% rename from packages/app-vanitygen/src/generator/types.js rename to packages/app-vanitygen/src/generator/types.d.ts index 9bbd28d6f7..8144113a7a 100644 --- a/packages/app-vanitygen/src/generator/types.js +++ b/packages/app-vanitygen/src/generator/types.d.ts @@ -1,7 +1,6 @@ // Copyright 2017-2018 @polkadot/app-vanitygen authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow export type Generator$Calculation = { count: number, diff --git a/packages/app-vanitygen/src/index.js b/packages/app-vanitygen/src/index.tsx similarity index 95% rename from packages/app-vanitygen/src/index.js rename to packages/app-vanitygen/src/index.tsx index 512956a165..7b811071e6 100644 --- a/packages/app-vanitygen/src/index.js +++ b/packages/app-vanitygen/src/index.tsx @@ -1,10 +1,9 @@ // Copyright 2017-2018 @polkadot/app-vanitygen authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { I18nProps } from '@polkadot/ui-app/types'; -import type { Generator$Matches, Generator$Result } from './generator/types'; +import { I18nProps } from '@polkadot/ui-app/types'; +import { Generator$Matches, Generator$Result } from './generator/types'; import './index.css'; @@ -56,7 +55,7 @@ class VanityApp extends React.PureComponent { withCase: true }; - render (): React$Node { + render () { const { className, style } = this.props; return ( @@ -72,7 +71,7 @@ class VanityApp extends React.PureComponent { ); } - renderButtons (): React$Node { + renderButtons () { const { t } = this.props; const { isMatchValid, isRunning } = this.state; @@ -92,7 +91,7 @@ class VanityApp extends React.PureComponent { ); } - renderMatches (): React$Node { + renderMatches () { const { matches } = this.state; return ( @@ -108,7 +107,7 @@ class VanityApp extends React.PureComponent { ); } - renderOptions (): React$Node { + renderOptions () { const { t } = this.props; const { isMatchValid, isRunning, match, withCase } = this.state; @@ -147,7 +146,7 @@ class VanityApp extends React.PureComponent { ); } - renderStats (): React$Node { + renderStats () { const { t } = this.props; const { elapsed, keyCount } = this.state; diff --git a/packages/app-vanitygen/src/translate.js b/packages/app-vanitygen/src/translate.ts similarity index 96% rename from packages/app-vanitygen/src/translate.js rename to packages/app-vanitygen/src/translate.ts index 093a8dbcaa..ed34f76e83 100644 --- a/packages/app-vanitygen/src/translate.js +++ b/packages/app-vanitygen/src/translate.ts @@ -1,7 +1,6 @@ // Copyright 2017-2018 @polkadot/app-vanitygen authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow import { translate } from 'react-i18next'; diff --git a/packages/apps/package.json b/packages/apps/package.json index a1e332465b..394991c883 100644 --- a/packages/apps/package.json +++ b/packages/apps/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/apps", - "version": "0.17.15", + "version": "0.18.0", "description": "An Apps portal into the Polkadot network", "main": "index.js", "homepage": ".", @@ -16,17 +16,17 @@ "check": "stylelint 'src/**/*.css' && eslint src && flow check" }, "dependencies": { - "@babel/runtime": "^7.0.0-beta.47", - "@polkadot/app-accounts": "^0.17.15", - "@polkadot/app-addresses": "^0.17.15", - "@polkadot/app-explorer": "^0.17.15", - "@polkadot/app-extrinsics": "^0.17.15", - "@polkadot/app-rpc": "^0.17.15", - "@polkadot/app-storage": "^0.17.15", - "@polkadot/app-toolbox": "^0.17.15", - "@polkadot/app-vanitygen": "^0.17.15", - "@polkadot/ui-app": "^0.17.15", - "@polkadot/ui-signer": "^0.17.15" + "@babel/runtime": "^7.0.0-beta.51", + "@polkadot/app-accounts": "^0.18.0", + "@polkadot/app-addresses": "^0.18.0", + "@polkadot/app-explorer": "^0.18.0", + "@polkadot/app-extrinsics": "^0.18.0", + "@polkadot/app-rpc": "^0.18.0", + "@polkadot/app-storage": "^0.18.0", + "@polkadot/app-toolbox": "^0.18.0", + "@polkadot/app-vanitygen": "^0.18.0", + "@polkadot/ui-app": "^0.18.0", + "@polkadot/ui-signer": "^0.18.0" }, "devDependencies": { "babel-loader": "^8.0.0-beta.2", diff --git a/packages/apps/src/Connecting/index.js b/packages/apps/src/Connecting/index.js deleted file mode 100644 index 660fedf41b..0000000000 --- a/packages/apps/src/Connecting/index.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2017-2018 @polkadot/apps authors & contributors -// This software may be modified and distributed under the terms -// of the ISC license. See the LICENSE file for details. -// @flow - -import type { I18nProps } from '@polkadot/ui-app/types'; -import type { ApiProps } from '@polkadot/ui-react-rx/types'; - -import './Connecting.css'; - -import React from 'react'; - -import classes from '@polkadot/ui-app/util/classes'; -import withApi from '@polkadot/ui-react-rx/with/api'; - -import translate from '../translate'; - -type Props = I18nProps & ApiProps; - -function Connecting ({ apiConnected, className, style, t }: Props): React$Node { - if (apiConnected) { - return null; - } - - return ( -

-
- {t('connecting.disconnected', { - defaultValue: 'You are not connected to a node. Ensure that your node is running and that the Websocket endpoint is reachable.' - })} -
-
- ); -} - -export default translate( - withApi(Connecting) -); diff --git a/packages/apps/src/Connecting/index.tsx b/packages/apps/src/Connecting/index.tsx new file mode 100644 index 0000000000..2f3b96d815 --- /dev/null +++ b/packages/apps/src/Connecting/index.tsx @@ -0,0 +1,44 @@ +// Copyright 2017-2018 @polkadot/apps authors & contributors +// This software may be modified and distributed under the terms +// of the ISC license. See the LICENSE file for details. + +import { I18nProps } from '@polkadot/ui-app/types'; +import { ApiProps } from '@polkadot/ui-react-rx/types'; + +import './Connecting.css'; + +import React from 'react'; + +import classes from '@polkadot/ui-app/util/classes'; +import withApi from '@polkadot/ui-react-rx/with/api'; + +import translate from '../translate'; + +type Props = I18nProps & ApiProps; + +class Connecting extends React.PureComponent { + render () { + const { apiConnected, className, style, t } = this.props; + + if (apiConnected) { + return null; + } + + return ( +
+
+ {t('connecting.disconnected', { + defaultValue: 'You are not connected to a node. Ensure that your node is running and that the Websocket endpoint is reachable.' + })} +
+
+ ); + } +} + +export default translate( + withApi(Connecting) +); diff --git a/packages/apps/src/Content/index.js b/packages/apps/src/Content/index.js deleted file mode 100644 index 4f6396463f..0000000000 --- a/packages/apps/src/Content/index.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2017-2018 @polkadot/apps authors & contributors -// This software may be modified and distributed under the terms -// of the ISC license. See the LICENSE file for details. -// @flow - -import type { Location } from 'react-router-dom'; -import type { I18nProps } from '@polkadot/ui-app/types'; - -import './Content.css'; - -import React from 'react'; -import { withRouter } from 'react-router'; - -import classes from '@polkadot/ui-app/util/classes'; - -import routing from '../routing'; - -type Props = I18nProps & { - location: Location -}; - -function Content ({ children, className, location, style }: Props): React$Node { - const app = location.pathname.slice(1) || routing.default; - const { Component } = routing.routes.find((route) => - route && route.name === app - ) || routing.unknown; - - return ( -
- -
- ); -} - -export default withRouter(Content); diff --git a/packages/apps/src/Content/index.tsx b/packages/apps/src/Content/index.tsx new file mode 100644 index 0000000000..10723b94ae --- /dev/null +++ b/packages/apps/src/Content/index.tsx @@ -0,0 +1,44 @@ +// Copyright 2017-2018 @polkadot/apps authors & contributors +// This software may be modified and distributed under the terms +// of the ISC license. See the LICENSE file for details. + +import { I18nProps } from '@polkadot/ui-app/types'; +import { Route } from '../types'; + +import './Content.css'; + +import React from 'react'; +import { withRouter } from 'react-router'; + +import classes from '@polkadot/ui-app/util/classes'; + +import routing from '../routing'; + +type Props = I18nProps & { + location: Location +}; + +class Content extends React.PureComponent { + render () { + const { className, location, style } = this.props; + + const app = location.pathname.slice(1) || routing.default; + const { Component } = routing.routes.find((route: Route | null) => + route + ? route.name === app + : false + ) || routing.unknown; + + return ( +
+ +
+ ); + } +} + +// @ts-ignore Ok, here the definition doesn't like this one... at all :( +export default withRouter(Content); diff --git a/packages/apps/src/NodeInfo.js b/packages/apps/src/NodeInfo.tsx similarity index 82% rename from packages/apps/src/NodeInfo.js rename to packages/apps/src/NodeInfo.tsx index 1724e1c95e..eb2b32bd43 100644 --- a/packages/apps/src/NodeInfo.js +++ b/packages/apps/src/NodeInfo.tsx @@ -1,14 +1,13 @@ // Copyright 2017-2018 @polkadot/apps authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { I18nProps } from '@polkadot/ui-app/types'; +import { I18nProps } from '@polkadot/ui-app/types'; import React from 'react'; import classes from '@polkadot/ui-app/util/classes'; -import keyring from '@polkadot/ui-keyring'; +import keyring from '@polkadot/ui-keyring/index'; import Chain from '@polkadot/ui-react-rx/Chain'; import NodeName from '@polkadot/ui-react-rx/NodeName'; import NodeVersion from '@polkadot/ui-react-rx/NodeVersion'; @@ -18,11 +17,10 @@ import translate from './translate'; type Props = I18nProps & {}; function updateTestInfo (chain?: string) { - console.log('updateTestInfo:chain', chain); keyring.setTestMode(chain === 'dev'); } -function NodeInfo ({ className, style, t }: Props): React$Node { +function NodeInfo ({ className, style, t }: Props) { return (
, - i18n: I18Next$Translate$Config, - icon: string, + Component: React.ComponentType, + i18n: any, // I18Next$Translate$Config, + icon: SemanticICONS, isExact: boolean, isHidden: boolean, name: string, diff --git a/packages/apps/webpack.config.js b/packages/apps/webpack.config.js index 1b59c792c1..b67ae038ae 100644 --- a/packages/apps/webpack.config.js +++ b/packages/apps/webpack.config.js @@ -24,7 +24,7 @@ function createWebpack ({ alias = {}, context, name = 'index' }) { return { context, devtool: isProd ? 'source-map' : 'cheap-eval-source-map', - entry: `./src/${name}.js`, + entry: `./src/${name}.tsx`, mode: ENV, output: { path: path.join(context, 'build'), @@ -32,7 +32,8 @@ function createWebpack ({ alias = {}, context, name = 'index' }) { chunkFilename: `[name].[chunkhash:8].js` }, resolve: { - alias + alias, + extensions: ['.js', '.jsx', '.ts', '.tsx'] }, module: { rules: [ @@ -77,7 +78,7 @@ function createWebpack ({ alias = {}, context, name = 'index' }) { ] }, { - test: /\.js$/, + test: /\.(js|ts|tsx)$/, exclude: /(node_modules)/, use: [ require.resolve('thread-loader'), diff --git a/packages/ui-app/package.json b/packages/ui-app/package.json index c31e1feb63..4d031a6a08 100644 --- a/packages/ui-app/package.json +++ b/packages/ui-app/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/ui-app", - "version": "0.17.15", + "version": "0.18.0", "main": "index.js", "repository": "https://github.com/polkadot-js/apps.git", "author": "Jaco Greeff ", @@ -15,20 +15,27 @@ "test": "jest --coverage" }, "dependencies": { - "@babel/runtime": "^7.0.0-beta.47", - "@polkadot/extrinsics": "^0.17.24", - "@polkadot/storage": "^0.17.24", - "@polkadot/ui-keyring": "^0.17.15", - "@polkadot/ui-react": "^0.17.15", - "@polkadot/ui-react-rx": "^0.17.15", + "@babel/runtime": "^7.0.0-beta.51", + "@polkadot/extrinsics": "^0.19.5", + "@polkadot/storage": "^0.19.5", + "@polkadot/ui-keyring": "^0.18.0", + "@polkadot/ui-react": "^0.18.0", + "@polkadot/ui-react-rx": "^0.18.0", + "@types/i18next-browser-languagedetector": "^2.0.1", + "@types/i18next-xhr-backend": "^1.4.1", + "@types/react-copy-to-clipboard": "^4.2.5", + "@types/react-dropzone": "^4.2.0", + "@types/react-i18next": "^7.6.1", + "@types/react-router-dom": "^4.2.7", "i18next": "^11.1.1", "i18next-browser-languagedetector": "^2.2.0", "i18next-xhr-backend": "^1.5.1", - "react": "^16.4.0", + "react": "^16.4.1", "react-copy-to-clipboard": "^5.0.1", - "react-dom": "^16.4.0", - "react-i18next": "^7.5.1", - "react-router-dom": "^4.2.2", + "react-dom": "^16.4.1", + "react-i18next": "^7.7.0", + "react-router": "^4.3.1", + "react-router-dom": "^4.3.1", "semantic-ui-css": "^2.3.1", "semantic-ui-react": "^0.80.0", "store": "^2.0.12" diff --git a/packages/ui-app/src/Button/Divider.js b/packages/ui-app/src/Button/Divider.tsx similarity index 73% rename from packages/ui-app/src/Button/Divider.js rename to packages/ui-app/src/Button/Divider.tsx index f8e7f3f2cd..2b0218f8d3 100644 --- a/packages/ui-app/src/Button/Divider.js +++ b/packages/ui-app/src/Button/Divider.tsx @@ -1,17 +1,14 @@ // Copyright 2017-2018 @polkadot/ui-app authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { BareProps } from '../types'; +import { DividerProps } from './types'; import React from 'react'; import classes from '../util/classes'; -type Props = BareProps; - -function ButtonDivider ({ className, style }: Props): React$Node { +function ButtonDivider ({ className, style }: DividerProps) { return (
void | Promise, - size?: Button$Sizes, - // flowlint-next-line unclear-type:off - text?: any -}; - -function Button ({ children, className, floated, icon, isBasic = false, isCircular = false, isDisabled = false, isNegative = false, isPrimary = false, onClick, size, style, text }: Props): React$Node { +function Button ({ children, className, floated, icon, isBasic = false, isCircular = false, isDisabled = false, isNegative = false, isPrimary = false, onClick, size, style, text }: ButtonProps) { const props = { basic: isBasic, circular: isCircular, @@ -60,8 +42,8 @@ function Button ({ children, className, floated, icon, isBasic = false, isCircul ); } -Button.Divider = Divider; -Button.Group = Group; -Button.Or = Or; +(Button as ButtonType).Divider = Divider; +(Button as ButtonType).Group = Group; +(Button as ButtonType).Or = Or; -export default Button; +export default (Button as ButtonType); diff --git a/packages/ui-app/src/Button/types.d.ts b/packages/ui-app/src/Button/types.d.ts new file mode 100644 index 0000000000..2b351ae38a --- /dev/null +++ b/packages/ui-app/src/Button/types.d.ts @@ -0,0 +1,37 @@ +// Copyright 2017-2018 @polkadot/ui-app authors & contributors +// This software may be modified and distributed under the terms +// of the ISC license. See the LICENSE file for details. + +import { BareProps } from '../types'; + +export type Button$Sizes = 'mini' | 'tiny' | 'small' | 'medium' | 'large' | 'big' | 'huge' | 'massive'; + +export type ButtonProps = BareProps & { + children?: any, + floated?: 'left' | 'right', + icon?: string, + isBasic?: boolean, + isCircular?: boolean, + isDisabled?: boolean, + isNegative?: boolean, + isPrimary?: boolean, + onClick?: () => void | Promise, + size?: Button$Sizes, + text?: any +}; + +export type DividerProps = BareProps; + +export type GroupProps = BareProps & { + children?: any +}; + +export type GroupType = React.ComponentType & { + Divider: React.ComponentType +} + +export type ButtonType = React.ComponentType & { + Divider: React.ComponentType, + Group: GroupType, + Or: React.ComponentType +} diff --git a/packages/ui-app/src/CopyButton.js b/packages/ui-app/src/CopyButton.tsx similarity index 85% rename from packages/ui-app/src/CopyButton.js rename to packages/ui-app/src/CopyButton.tsx index f3ad7b5b5c..59bb086a13 100644 --- a/packages/ui-app/src/CopyButton.js +++ b/packages/ui-app/src/CopyButton.tsx @@ -1,10 +1,9 @@ // Copyright 2017-2018 @polkadot/ui-app authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -// @flow -import type { Button$Sizes } from './Button'; -import type { BareProps } from './types'; +import { Button$Sizes } from './Button/types'; +import { BareProps } from './types'; import React from 'react'; import CopyToClipboard from 'react-copy-to-clipboard'; @@ -16,10 +15,10 @@ type Props = BareProps & { isCircular?: boolean, isPrimary?: boolean, size?: Button$Sizes, - value?: mixed + value?: any } -export default function CopyButton ({ className, icon = 'copy', isCircular = true, isPrimary = true, size = 'tiny', style, value }: Props): React$Node { +export default function CopyButton ({ className, icon = 'copy', isCircular = true, isPrimary = true, size = 'tiny', style, value }: Props) { return (