diff --git a/.babelrc b/.babelrc index 26ca3a9558..e138fa1828 100644 --- a/.babelrc +++ b/.babelrc @@ -1,4 +1,3 @@ { - "extends": "@polkadot/dev/config/babel", - "presets": ["react"] + "extends": "@polkadot/dev-react/config/babel" } diff --git a/.eslintrc.json b/.eslintrc.json index 1684179477..fbdde8630f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,5 +1,5 @@ { "extends": [ - "./node_modules/@polkadot/dev/config/eslint.js" + "./node_modules/@polkadot/dev-react/config/eslint.js" ] } diff --git a/.flowconfig b/.flowconfig index d5f6528570..90874500f9 100644 --- a/.flowconfig +++ b/.flowconfig @@ -6,12 +6,13 @@ [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\|vanitygen\)\(.*\)$' -> '/packages/app-\1/src\2' +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\|keyring\)\(.*\)$' -> '/packages/ui-\1/src\2' diff --git a/.stylelintrc.json b/.stylelintrc.json index aac632699f..8477594ade 100644 --- a/.stylelintrc.json +++ b/.stylelintrc.json @@ -1,3 +1,3 @@ { - "extends": "@polkadot/dev/config/stylelint" + "extends": "@polkadot/dev-react/config/stylelint" } diff --git a/flow-typed/i18next-browser-languagedetector.js b/flow-typed/i18next-browser-languagedetector.js deleted file mode 100644 index 3b754b0ea8..0000000000 --- a/flow-typed/i18next-browser-languagedetector.js +++ /dev/null @@ -1,5 +0,0 @@ -// @flow - -declare module 'i18next-browser-languagedetector' { - declare module.exports: {} -} diff --git a/flow-typed/i18next-xhr-backend.js b/flow-typed/i18next-xhr-backend.js deleted file mode 100644 index b7da247ada..0000000000 --- a/flow-typed/i18next-xhr-backend.js +++ /dev/null @@ -1,5 +0,0 @@ -// @flow - -declare module 'i18next-xhr-backend' { - declare module.exports: {} -} diff --git a/flow-typed/i18next.js b/flow-typed/i18next.js deleted file mode 100644 index a572b673e3..0000000000 --- a/flow-typed/i18next.js +++ /dev/null @@ -1,23 +0,0 @@ -// @flow - -declare type I18Next$Config = { - fallbackLng?: string, - ns?: Array, - defaultNS?: string, - debug?: boolean, - interpolation?: { - escapeValue: boolean - }, - react?: { - wait: boolean - } -}; - -declare module 'i18next' { - declare type I18Next = { - use: (any) => I18Next, - init: (I18Next$Config) => I18Next - }; - - declare module.exports: I18Next -} diff --git a/flow-typed/react-copy-to-clipboard.js b/flow-typed/react-copy-to-clipboard.js deleted file mode 100644 index 62255fb71e..0000000000 --- a/flow-typed/react-copy-to-clipboard.js +++ /dev/null @@ -1,5 +0,0 @@ -// @flow - -declare module 'react-copy-to-clipboard' { - declare module.exports: React$ComponentType<{ text?: string }>; -} diff --git a/flow-typed/react-dropzone.js b/flow-typed/react-dropzone.js deleted file mode 100644 index f5978dc04f..0000000000 --- a/flow-typed/react-dropzone.js +++ /dev/null @@ -1,6 +0,0 @@ -// @flow - -declare module 'react-dropzone' { - declare type Dropzone = React$StatelessFunctionalComponent<*>; - declare module.exports: Dropzone; -} diff --git a/flow-typed/react-i18next.js b/flow-typed/react-i18next.js deleted file mode 100644 index 5efa99a1f3..0000000000 --- a/flow-typed/react-i18next.js +++ /dev/null @@ -1,19 +0,0 @@ -// @flow - -declare type I18Next$Translate$Config = { - defaultValue: string, - replace?: { - [string]: any - } -}; - -declare type I18Next$Translate = (key: string, config: I18Next$Translate$Config) => string; - -declare module 'react-i18next' { - declare module.exports: { - I18nextProvider: React$StatelessFunctionalComponent<*>, - Trans: React$StatelessFunctionalComponent<*>, - reactI18nextModule: {}, - translate: (context: string | Array) => (Component: React$ComponentType<*>) => React$StatelessFunctionalComponent<*> - } -} diff --git a/flow-typed/react-remarkable.js b/flow-typed/react-remarkable.js deleted file mode 100644 index 9c4e578f1e..0000000000 --- a/flow-typed/react-remarkable.js +++ /dev/null @@ -1,5 +0,0 @@ -// @flow - -declare module 'react-remarkable' { - declare module.exports: React$StatelessFunctionalComponent<*> -} diff --git a/flow-typed/react-router.js b/flow-typed/react-router.js deleted file mode 100644 index c4d7c15185..0000000000 --- a/flow-typed/react-router.js +++ /dev/null @@ -1,7 +0,0 @@ -// @flow - -declare module 'react-router' { - declare module.exports: { - withRouter: (Component: React$ComponentType<*>) => React$StatelessFunctionalComponent<*>; - } -} diff --git a/jest.config.js b/jest.config.js index d3bc456aec..f30e81fa36 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1 +1 @@ -module.exports = require('@polkadot/dev/config/jest'); +module.exports = require('@polkadot/dev-react/config/jest'); diff --git a/lerna.json b/lerna.json index a5586ad6a3..88fac6520f 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "lerna": "2.5.1", + "lerna": "2.11.0", "npmClient": "yarn", "useWorkspaces": true, "command": { @@ -10,5 +10,5 @@ "packages": [ "packages/*" ], - "version": "0.4.12" + "version": "0.5.0" } diff --git a/package.json b/package.json index 45e6e1cda9..d79d5fc182 100644 --- a/package.json +++ b/package.json @@ -9,16 +9,15 @@ "build": "polkadot-dev-build-babel && yarn run build:apps", "build:apps": "cd packages/apps && react-scripts build", "check": "eslint packages && flow check", + "clean": "polkadot-dev-clean-build", "deploy:ghpages": "gh-pages -d packages/apps/build", "vanitygen": "polkadot-dev-build-babel && node packages/app-vanitygen/build/generator/cli.js", "start": "cd packages/apps && react-scripts start", "test": "echo 'no tests executed'" }, "devDependencies": { - "@polkadot/dev": "^0.17.13", - "babel-preset-react": "^6.24.1", + "@polkadot/dev-react": "^0.18.3", "gh-pages": "^1.1.0", - "lerna": "^2.5.1", "react-scripts": "2.0.0-next.66cc7a90" }, "browserslist": { diff --git a/packages/app-accounts/package.json b/packages/app-accounts/package.json index 959ffbe3bd..b793dd682c 100644 --- a/packages/app-accounts/package.json +++ b/packages/app-accounts/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/app-accounts", - "version": "0.4.12", + "version": "0.5.0", "main": "index.js", "repository": "https://github.com/polkadot-js/apps.git", "author": "Jaco Greeff ", @@ -11,6 +11,6 @@ "test": "jest --coverage" }, "devDependencies": { - "@polkadot/ui-app": "^0.4.12" + "@polkadot/ui-app": "^0.5.0" } } diff --git a/packages/app-accounts/src/Address.js b/packages/app-accounts/src/Address.js index 2f033caa4e..793ecdb146 100644 --- a/packages/app-accounts/src/Address.js +++ b/packages/app-accounts/src/Address.js @@ -8,6 +8,7 @@ import type { BareProps } from '@polkadot/ui-app/types'; import React from 'react'; import CopyButton from '@polkadot/ui-app/src/CopyButton'; +import classes from '@polkadot/ui-app/src/util/classes'; import IdentityIcon from '@polkadot/ui-react/IdentityIcon'; import Balance from '@polkadot/ui-react-rx/Balance'; import Nonce from '@polkadot/ui-react-rx/Nonce'; @@ -58,7 +59,7 @@ export default class Address extends React.PureComponent { return (
{ return (
diff --git a/packages/app-accounts/src/Editor.js b/packages/app-accounts/src/Editor.js index 58a59d76ef..aa9b791c38 100644 --- a/packages/app-accounts/src/Editor.js +++ b/packages/app-accounts/src/Editor.js @@ -11,6 +11,7 @@ import React from 'react'; import Button from '@polkadot/ui-app/src/Button'; import Input from '@polkadot/ui-app/src/Input'; import InputAddress from '@polkadot/ui-app/src/InputAddress'; +import classes from '@polkadot/ui-app/src/util/classes'; import keyring from '@polkadot/ui-keyring/src'; import Address from './Address'; @@ -49,7 +50,7 @@ class Editor extends React.PureComponent { if (!currentPair) { return (
{t('editor.none', { @@ -63,7 +64,7 @@ class Editor extends React.PureComponent { return (
@@ -77,7 +78,7 @@ class Editor extends React.PureComponent { className='full' defaultValue={defaultPublicKey} hideAddress - isSUIInput={false} + isInput={false} label={t('editor.select', { defaultValue: 'using my account' })} diff --git a/packages/app-accounts/src/index.css b/packages/app-accounts/src/index.css index 411dd2f9d5..7869a05c98 100644 --- a/packages/app-accounts/src/index.css +++ b/packages/app-accounts/src/index.css @@ -12,6 +12,7 @@ } .accounts--Address { + padding: 0 2em; text-align: center; } @@ -39,7 +40,7 @@ } .accounts--Address-data { - padding: 0.5em 2em; + padding: 0.5em 0; } .accounts--Address-data * { diff --git a/packages/app-accounts/src/index.js b/packages/app-accounts/src/index.js index 649809433d..3946f5e44e 100644 --- a/packages/app-accounts/src/index.js +++ b/packages/app-accounts/src/index.js @@ -10,6 +10,7 @@ import './index.css'; import React from 'react'; import Button from '@polkadot/ui-app/src/Button'; +import classes from '@polkadot/ui-app/src/util/classes'; import Creator from './Creator'; import Editor from './Editor'; @@ -24,7 +25,8 @@ type State = { } // FIXME React-router would probably be the best route, not home-grown -const Components: { [Actions]: React$ComponentType<*> } = { +// flowlint-next-line unclear-type:off +const Components: { [Actions]: React$ComponentType } = { 'create': Creator, 'edit': Editor }; @@ -39,7 +41,7 @@ class App extends React.PureComponent { return (
diff --git a/packages/app-addresses/package.json b/packages/app-addresses/package.json index 486bca512f..1634ec76da 100644 --- a/packages/app-addresses/package.json +++ b/packages/app-addresses/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/app-addresses", - "version": "0.4.12", + "version": "0.5.0", "main": "index.js", "repository": "https://github.com/polkadot-js/apps.git", "author": "Jaco Greeff ", @@ -11,7 +11,7 @@ "test": "jest --coverage" }, "devDependencies": { - "@polkadot/app-accounts": "^0.4.12", - "@polkadot/ui-app": "^0.4.12" + "@polkadot/app-accounts": "^0.5.0", + "@polkadot/ui-app": "^0.5.0" } } diff --git a/packages/app-addresses/src/Creator.js b/packages/app-addresses/src/Creator.js index a5e50f8db2..cd02c9583f 100644 --- a/packages/app-addresses/src/Creator.js +++ b/packages/app-addresses/src/Creator.js @@ -9,6 +9,7 @@ import React from 'react'; import Button from '@polkadot/ui-app/src/Button'; import Input from '@polkadot/ui-app/src/Input'; +import classes from '@polkadot/ui-app/src/util/classes'; import keyring from '@polkadot/ui-keyring/src'; import addressDecode from '@polkadot/util-keyring/address/decode'; import addressEncode from '@polkadot/util-keyring/address/encode'; @@ -43,7 +44,7 @@ class Creator extends React.PureComponent { return (
diff --git a/packages/app-addresses/src/Editor.js b/packages/app-addresses/src/Editor.js index 3c1493092b..11e7f42c95 100644 --- a/packages/app-addresses/src/Editor.js +++ b/packages/app-addresses/src/Editor.js @@ -11,6 +11,7 @@ import React from 'react'; import Button from '@polkadot/ui-app/src/Button'; import Input from '@polkadot/ui-app/src/Input'; import InputAddress from '@polkadot/ui-app/src/InputAddress'; +import classes from '@polkadot/ui-app/src/util/classes'; import keyring from '@polkadot/ui-keyring/src'; import Address from '@polkadot/app-accounts/src/Address'; @@ -50,7 +51,7 @@ class Editor extends React.PureComponent { if (!currentAddress) { return (
{t('editor.none', { @@ -64,7 +65,7 @@ class Editor extends React.PureComponent { return (
diff --git a/packages/app-addresses/src/index.js b/packages/app-addresses/src/index.js index f0a0b11ca8..71acdaeda5 100644 --- a/packages/app-addresses/src/index.js +++ b/packages/app-addresses/src/index.js @@ -10,6 +10,7 @@ import './index.css'; import React from 'react'; import Button from '@polkadot/ui-app/src/Button'; +import classes from '@polkadot/ui-app/src/util/classes'; import Creator from './Creator'; import Editor from './Editor'; @@ -24,7 +25,8 @@ type State = { } // FIXME React-router would probably be the best route, not home-grown -const Components: { [Actions]: React$ComponentType<*> } = { +// flowlint-next-line unclear-type:off +const Components: { [Actions]: React$ComponentType } = { 'create': Creator, 'edit': Editor }; @@ -39,7 +41,7 @@ class App extends React.PureComponent { return (
diff --git a/packages/app-explorer/package.json b/packages/app-explorer/package.json index 303d46f9e7..7beef622c2 100644 --- a/packages/app-explorer/package.json +++ b/packages/app-explorer/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/app-explorer", - "version": "0.4.12", + "version": "0.5.0", "main": "index.js", "repository": "https://github.com/polkadot-js/apps.git", "author": "Jaco Greeff ", @@ -11,10 +11,10 @@ "test": "jest --coverage" }, "devDependencies": { - "@polkadot/primitives": "^0.13.8", - "@polkadot/primitives-codec": "^0.13.8", - "@polkadot/primitives-json": "^0.13.8", - "@polkadot/ui-app": "^0.4.12", - "@polkadot/util-crypto": "^0.19.6" + "@polkadot/primitives": "^0.13.10", + "@polkadot/primitives-codec": "^0.13.10", + "@polkadot/primitives-json": "^0.13.10", + "@polkadot/ui-app": "^0.5.0", + "@polkadot/util-crypto": "^0.19.7" } } diff --git a/packages/app-explorer/src/BlockHeader/index.js b/packages/app-explorer/src/BlockHeader/index.js index 0053f83f65..0d3bf6331c 100644 --- a/packages/app-explorer/src/BlockHeader/index.js +++ b/packages/app-explorer/src/BlockHeader/index.js @@ -11,6 +11,7 @@ import './BlockHeader.css'; import React from 'react'; import headerHash from '@polkadot/primitives-codec/header/hash'; +import classes from '@polkadot/ui-app/src/util/classes'; import u8aToHex from '@polkadot/util/u8a/toHex'; import translate from '../translate'; @@ -30,7 +31,7 @@ function BlockHeader ({ className, label = '#', value, style }: Props): React$No return (
diff --git a/packages/app-explorer/src/index.js b/packages/app-explorer/src/index.js index 249605754f..7a277fd266 100644 --- a/packages/app-explorer/src/index.js +++ b/packages/app-explorer/src/index.js @@ -9,6 +9,7 @@ import './index.css'; import React from 'react'; +import classes from '@polkadot/ui-app/src/util/classes'; import BestNumber from '@polkadot/ui-react-rx/BestNumber'; import BestHash from './BestHash'; @@ -20,7 +21,7 @@ type Props = I18nProps & {}; function App ({ className, style, t }: Props): React$Node { return (
", @@ -11,9 +11,9 @@ "test": "jest --coverage" }, "devDependencies": { - "@polkadot/extrinsics": "^0.13.8", - "@polkadot/extrinsics-codec": "^0.13.8", - "@polkadot/ui-app": "^0.4.12", + "@polkadot/extrinsics": "^0.13.10", + "@polkadot/extrinsics-codec": "^0.13.10", + "@polkadot/ui-app": "^0.5.0", "react-dropzone": "^4.2.9" } } diff --git a/packages/app-extrinsics/src/Account.js b/packages/app-extrinsics/src/Account.js index bcb6d24948..db61194dae 100644 --- a/packages/app-extrinsics/src/Account.js +++ b/packages/app-extrinsics/src/Account.js @@ -10,6 +10,7 @@ import React from 'react'; import InputAddress from '@polkadot/ui-app/src/InputAddress'; import Labelled from '@polkadot/ui-app/src/Labelled'; +import classes from '@polkadot/ui-app/src/util/classes'; import Balance from '@polkadot/ui-react-rx/Balance'; import translate from './translate'; @@ -45,7 +46,7 @@ class Account extends React.PureComponent { return (
diff --git a/packages/app-extrinsics/src/Extrinsic.js b/packages/app-extrinsics/src/Extrinsic.js index ebde8e23d7..ebab9e46ff 100644 --- a/packages/app-extrinsics/src/Extrinsic.js +++ b/packages/app-extrinsics/src/Extrinsic.js @@ -13,6 +13,7 @@ import React from 'react'; import encode from '@polkadot/extrinsics-codec/encode/extrinsic'; import InputExtrinsic from '@polkadot/ui-app/src/InputExtrinsic'; import Params from '@polkadot/ui-app/src/Params'; +import classes from '@polkadot/ui-app/src/util/classes'; import isUndefined from '@polkadot/util/is/undefined'; import paramComponents from './Params'; @@ -48,7 +49,7 @@ export default class ExtrinsicDisplay extends React.PureComponent return (
{ return (
diff --git a/packages/app-extrinsics/src/Signer/Unlock.js b/packages/app-extrinsics/src/Signer/Unlock.js index 03c4bb7c68..b599f6a299 100644 --- a/packages/app-extrinsics/src/Signer/Unlock.js +++ b/packages/app-extrinsics/src/Signer/Unlock.js @@ -9,6 +9,7 @@ import type { KeyringPair } from '@polkadot/util-keyring/types'; import React from 'react'; import Password from '@polkadot/ui-app/src/Password'; +import classes from '@polkadot/ui-app/src/util/classes'; import keyring from '@polkadot/ui-keyring/src'; import translate from '../translate'; @@ -51,7 +52,7 @@ class Unlock extends React.PureComponent { return (
diff --git a/packages/app-extrinsics/src/Signer/index.js b/packages/app-extrinsics/src/Signer/index.js index d9e7c6efcd..40167fe029 100644 --- a/packages/app-extrinsics/src/Signer/index.js +++ b/packages/app-extrinsics/src/Signer/index.js @@ -13,6 +13,7 @@ import React from 'react'; import Button from '@polkadot/ui-app/src/Button'; import Modal from '@polkadot/ui-app/src/Modal'; +import classes from '@polkadot/ui-app/src/util/classes'; import keyring from '@polkadot/ui-keyring/src'; import withApi from '@polkadot/ui-react-rx/with/api'; @@ -69,7 +70,7 @@ class Signer extends React.PureComponent { return ( } @@ -23,12 +25,12 @@ export default function Status ({ className, queue, style }: Props): React$Node return (
{available.map(({ extrinsic: { name, section }, id, status }) =>
diff --git a/packages/app-extrinsics/src/index.js b/packages/app-extrinsics/src/index.js index 2de0cd28fa..bda8c2b238 100644 --- a/packages/app-extrinsics/src/index.js +++ b/packages/app-extrinsics/src/index.js @@ -10,6 +10,8 @@ import './index.css'; import React from 'react'; +import classes from '@polkadot/ui-app/src/util/classes'; + import Selection from './Selection'; import Signer from './Signer'; import Status from './Status'; @@ -31,7 +33,7 @@ export default class App extends React.PureComponent { return (
diff --git a/packages/app-storage/package.json b/packages/app-storage/package.json index 39ca8e0189..aec321026f 100644 --- a/packages/app-storage/package.json +++ b/packages/app-storage/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/app-storage", - "version": "0.4.12", + "version": "0.5.0", "main": "index.js", "repository": "https://github.com/polkadot-js/apps.git", "author": "Jaco Greeff ", @@ -11,6 +11,6 @@ "test": "jest --coverage" }, "devDependencies": { - "@polkadot/ui-app": "^0.4.12" + "@polkadot/ui-app": "^0.5.0" } } diff --git a/packages/app-storage/src/Queries.js b/packages/app-storage/src/Queries.js index 4d7cb79c84..74fee5dafa 100644 --- a/packages/app-storage/src/Queries.js +++ b/packages/app-storage/src/Queries.js @@ -8,6 +8,8 @@ import type { StorageQuery } from './types'; import React from 'react'; +import classes from '@polkadot/ui-app/src/util/classes'; + import translate from './translate'; import Query from './Query'; @@ -23,7 +25,7 @@ function Queries ({ className, onRemove, style, value }: Props): React$Node { return (
{value.map((query) => diff --git a/packages/app-storage/src/Query.js b/packages/app-storage/src/Query.js index bbc5de439a..0f5a493088 100644 --- a/packages/app-storage/src/Query.js +++ b/packages/app-storage/src/Query.js @@ -12,6 +12,7 @@ import Button from '@polkadot/ui-app/src/Button'; import Labelled from '@polkadot/ui-app/src/Labelled'; import typeToText from '@polkadot/ui-app/src/Params/typeToText'; import valueToText from '@polkadot/ui-app/src/Params/valueToText'; +import classes from '@polkadot/ui-app/src/util/classes'; import withStorageDiv from '@polkadot/ui-react-rx/with/storageDiv'; import translate from './translate'; @@ -23,7 +24,8 @@ type Props = I18nProps & { type State = { inputs: Array, - Component: React$ComponentType<*>; + // flowlint-next-line unclear-type:off + Component: React$ComponentType; }; const cache = []; @@ -32,14 +34,15 @@ class Query extends React.PureComponent { state: State = ({}: $Shape); static getDerivedStateFromProps ({ value: { id, key, params } }: Props, prevState: State): State | null { - const Component = ((): React$ComponentType<*> => { + // flowlint-next-line unclear-type:off + const Component = ((): React$ComponentType => { if (!cache[id]) { const values = params.map(({ value }) => value); cache[id] = withStorageDiv(key, { params: values })( (value) => valueToText(key.type, value), - { className: 'ui disabled dropdown selection' } + { className: 'ui--output' } ); } @@ -67,7 +70,7 @@ class Query extends React.PureComponent { return (
{ return (
diff --git a/packages/app-storage/src/index.js b/packages/app-storage/src/index.js index 03a33658b9..3a014283b0 100644 --- a/packages/app-storage/src/index.js +++ b/packages/app-storage/src/index.js @@ -10,6 +10,8 @@ import './index.css'; import React from 'react'; +import classes from '@polkadot/ui-app/src/util/classes'; + import Queries from './Queries'; import Selection from './Selection'; import translate from './translate'; @@ -31,7 +33,7 @@ class App extends React.PureComponent { return (
diff --git a/packages/app-storage/src/types.js b/packages/app-storage/src/types.js index 59a6d9986d..a041b1fe62 100644 --- a/packages/app-storage/src/types.js +++ b/packages/app-storage/src/types.js @@ -8,5 +8,6 @@ import type { StorageDef$Key } from '@polkadot/storage/types'; export type StorageQuery = { id: number, key: StorageDef$Key, - params: Array<*> + // flowlint-next-line unclear-type:off + params: Array } diff --git a/packages/app-toolbox/LICENSE b/packages/app-toolbox/LICENSE new file mode 100644 index 0000000000..3d150a620a --- /dev/null +++ b/packages/app-toolbox/LICENSE @@ -0,0 +1,15 @@ +ISC License (ISC) + +Copyright 2017-2018 Jaco Greeff + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/packages/app-toolbox/README.md b/packages/app-toolbox/README.md new file mode 100644 index 0000000000..204a833808 --- /dev/null +++ b/packages/app-toolbox/README.md @@ -0,0 +1 @@ +# @polkadot/app-toolbox diff --git a/packages/app-toolbox/package.json b/packages/app-toolbox/package.json new file mode 100644 index 0000000000..84137c87fb --- /dev/null +++ b/packages/app-toolbox/package.json @@ -0,0 +1,17 @@ +{ + "name": "@polkadot/app-toolbox", + "version": "0.5.0", + "main": "index.js", + "repository": "https://github.com/polkadot-js/apps.git", + "author": "Jaco Greeff ", + "license": "ISC", + "scripts": { + "build": "polkadot-dev-build-babel", + "check": "stylelint 'src/**/*.css' && eslint src && flow check", + "test": "jest --coverage" + }, + "devDependencies": { + "@polkadot/ui-app": "^0.5.0", + "@polkadot/ui-keyring": "^0.5.0" + } +} diff --git a/packages/app-toolbox/src/Hash.js b/packages/app-toolbox/src/Hash.js new file mode 100644 index 0000000000..a876797720 --- /dev/null +++ b/packages/app-toolbox/src/Hash.js @@ -0,0 +1,95 @@ +// Copyright 2017-2018 Jaco Greeff +// 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 React from 'react'; + +import Input from '@polkadot/ui-app/src/Input'; +import Output from '@polkadot/ui-app/src/Output'; +import Static from '@polkadot/ui-app/src/Static'; +import classes from '@polkadot/ui-app/src/util/classes'; +import hexToU8a from '@polkadot/util/hex/toU8a'; +import isHex from '@polkadot/util/is/hex'; +import u8aFromString from '@polkadot/util/u8a/fromString'; +import xxhashAsHex256 from '@polkadot/util-crypto/xxhash/asHex256'; + +import translate from './translate'; + +type State = { + data: string, + hash: string, + isHexData: boolean +}; + +class Hash extends React.PureComponent { + state: State = { + data: '', + hash: xxhashAsHex256(u8aFromString('')), + isHexData: false + }; + + render (): React$Node { + const { className, style, t } = this.props; + const { data, hash, isHexData } = this.state; + + return ( +
+
+ + +
+
+ +
+
+ ); + } + + onChangeData = (data: string): void => { + const isHexData = isHex(data); + const hash = xxhashAsHex256( + isHexData + ? hexToU8a(data) + : u8aFromString(data) + ); + + this.setState({ data, hash, isHexData }); + } +} + +export default translate(Hash); diff --git a/packages/app-toolbox/src/Sign.js b/packages/app-toolbox/src/Sign.js new file mode 100644 index 0000000000..7803800d64 --- /dev/null +++ b/packages/app-toolbox/src/Sign.js @@ -0,0 +1,194 @@ +// Copyright 2017-2018 Jaco Greeff +// 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 React from 'react'; + +import Button from '@polkadot/ui-app/src/Button'; +import Input from '@polkadot/ui-app/src/Input'; +import InputAddress from '@polkadot/ui-app/src/InputAddress'; +import Output from '@polkadot/ui-app/src/Output'; +import Static from '@polkadot/ui-app/src/Static'; +import classes from '@polkadot/ui-app/src/util/classes'; +import keyring from '@polkadot/ui-keyring/src'; +import hexToU8a from '@polkadot/util/hex/toU8a'; +import isHex from '@polkadot/util/is/hex'; +import u8aFromString from '@polkadot/util/u8a/fromString'; +import u8aToHex from '@polkadot/util/u8a/toHex'; + +import Unlock from './Unlock'; +import translate from './translate'; + +type State = { + currentPair: KeyringPair | null, + defaultPublicKey?: Uint8Array, + data: string, + isHexData: boolean, + isLocked: boolean, + isUnlockVisible: boolean, + signature: string +}; + +class Sign extends React.PureComponent { + state: State; + + constructor (props: Props) { + super(props); + + const pairs = keyring.getPairs(); + const currentPair = pairs[0] || null; + + this.state = { + currentPair, + defaultPublicKey: currentPair + ? currentPair.publicKey() + : void 0, + data: '', + isHexData: false, + isLocked: currentPair + ? !currentPair.hasSecretKey() + : false, + isUnlockVisible: false, + signature: '' + }; + } + + render (): React$Node { + const { className, style, t } = this.props; + const { currentPair, data, defaultPublicKey, isHexData, isLocked, isUnlockVisible, signature } = this.state; + + return ( +
+
+ +
+
+ + +
+
+ +
+ + { + isLocked + ? ( + +
+ ); + } + + nextState = (newState: $Shape): void => { + this.setState( + (prevState: State): $Shape => { + const { currentPair = prevState.currentPair, data = prevState.data, isHexData = prevState.isHexData, isUnlockVisible = prevState.isUnlockVisible } = newState; + const isLocked = !currentPair || !currentPair.hasSecretKey(); + let signature = ''; + + if (!isLocked && currentPair) { + signature = u8aToHex( + currentPair.sign( + isHexData + ? hexToU8a(data) + : u8aFromString(data) + ) + ); + } + + return { + currentPair, + data, + isHexData, + isLocked, + isUnlockVisible, + signature + }; + } + ); + } + + toggleUnlock = (): void => { + const { isUnlockVisible } = this.state; + + this.nextState({ + isUnlockVisible: !isUnlockVisible + }); + } + + onChangeAccount = (publicKey: Uint8Array): void => { + const currentPair = keyring.getPair(publicKey); + + this.nextState({ currentPair }); + } + + onChangeData = (data: string): void => { + const isHexData = isHex(data); + + this.nextState({ data, isHexData }); + } + + onUnlock = (): void => { + } +} + +export default translate(Sign); diff --git a/packages/app-toolbox/src/Unlock.js b/packages/app-toolbox/src/Unlock.js new file mode 100644 index 0000000000..4a16b4239c --- /dev/null +++ b/packages/app-toolbox/src/Unlock.js @@ -0,0 +1,182 @@ +// Copyright 2017-2018 Jaco Greeff +// 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 React from 'react'; +import { Trans } from 'react-i18next'; + +import Button from '@polkadot/ui-app/src/Button'; +import Modal from '@polkadot/ui-app/src/Modal'; +import Password from '@polkadot/ui-app/src/Password'; +import classes from '@polkadot/ui-app/src/util/classes'; +import IdentityIcon from '@polkadot/ui-react/IdentityIcon'; + +import translate from './translate'; + +type Props = I18nProps & { + isVisible: boolean, + onClose: () => void, + pair: KeyringPair +}; + +type UnlockI18n = { + key: string, + value: I18Next$Translate$Config +} + +type State = { + address: string, + password: string, + unlockError: UnlockI18n | null +}; + +class Unlock extends React.PureComponent { + state: State = { + address: '', + password: '', + unlockError: null + }; + + static getDerivedStateFromProps ({ pair }: Props, prevState: State): $Shape { + const address = pair + ? pair.address() + : ''; + + const isSame = address !== prevState.address; + + return { + address, + password: isSame + ? prevState.password + : '', + unlockError: isSame + ? prevState.unlockError + : null + }; + } + + render (): React$Node { + const { className, isVisible, style, t } = this.props; + const { address, password, unlockError } = this.state; + + if (!isVisible) { + return null; + } + + return ( + + + {t('unlock.header', { + defaultValue: 'Unlock account' + })} + + +
+
+

+ + You are about to unlock your account {address} to allow for the signing of messages. + +

+
+ +
+
+
+ +
+
+
+ + +
+ ); + } + + selectHash = (): void => { + this.setState({ action: 'hash' }); + } + + selectSign = (): void => { + this.setState({ action: 'sign' }); + } + + selectVerify = (): void => { + this.setState({ action: 'verify' }); + } +} + +export default translate(App); diff --git a/packages/app-toolbox/src/translate.js b/packages/app-toolbox/src/translate.js new file mode 100644 index 0000000000..fbad038d2b --- /dev/null +++ b/packages/app-toolbox/src/translate.js @@ -0,0 +1,8 @@ +// Copyright 2017-2018 Jaco Greeff +// 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'; + +export default translate(['toolbox', 'ui']); diff --git a/packages/app-vanitygen/package.json b/packages/app-vanitygen/package.json index d17b430783..16a1319386 100644 --- a/packages/app-vanitygen/package.json +++ b/packages/app-vanitygen/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/app-vanitygen", - "version": "0.4.12", + "version": "0.5.0", "main": "index.js", "repository": "https://github.com/polkadot-js/apps.git", "author": "Jaco Greeff ", @@ -11,7 +11,7 @@ "test": "jest --coverage" }, "devDependencies": { - "@polkadot/ui-app": "^0.4.12", + "@polkadot/ui-app": "^0.5.0", "chalk": "^2.4.1", "yargs": "10.1.2" }, diff --git a/packages/app-vanitygen/src/Match.js b/packages/app-vanitygen/src/Match.js index ecc9398b8a..98411084cb 100644 --- a/packages/app-vanitygen/src/Match.js +++ b/packages/app-vanitygen/src/Match.js @@ -9,6 +9,7 @@ import React from 'react'; import CopyButton from '@polkadot/ui-app/src/CopyButton'; import Button from '@polkadot/ui-app/src/Button'; +import classes from '@polkadot/ui-app/src/util/classes'; import IdentityIcon from '@polkadot/ui-react/IdentityIcon'; import u8aToHex from '@polkadot/util/u8a/toHex'; @@ -39,7 +40,7 @@ export default class Match extends React.PureComponent { return (
diff --git a/packages/app-vanitygen/src/index.js b/packages/app-vanitygen/src/index.js index cb420dd37e..642fd847ce 100644 --- a/packages/app-vanitygen/src/index.js +++ b/packages/app-vanitygen/src/index.js @@ -13,7 +13,8 @@ import React from 'react'; import Button from '@polkadot/ui-app/src/Button'; import Dropdown from '@polkadot/ui-app/src/Dropdown'; import Input from '@polkadot/ui-app/src/Input'; -import Labelled from '@polkadot/ui-app/src/Labelled'; +import Static from '@polkadot/ui-app/src/Static'; +import classes from '@polkadot/ui-app/src/util/classes'; import Match from './Match'; import generator from './generator'; @@ -61,7 +62,7 @@ class App extends React.PureComponent { return (
@@ -85,18 +86,15 @@ class App extends React.PureComponent { onChange={this.onChangeCase} value={withCase} /> - -
- {t('vanity.offset.off', { - defaultValue: 'No' - })} -
-
+ value={t('vanity.offset.off', { + defaultValue: 'No' + })} + />