diff --git a/.eslintrc.json b/.eslintrc.json index 9f0c853c..d6212d8e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,9 +1,7 @@ { "extends": ["eslint:recommended", "plugin:react/recommended"], "parser": "babel-eslint", - "plugins": [ - "react" - ], + "plugins": ["react"], "parserOptions": { "ecmaFeatures": { "jsx": true, @@ -19,7 +17,7 @@ }, "rules": { "comma-dangle": 1, - "quotes": [ 1, "single" ], + "quotes": [1, "single"], "no-undef": 1, "global-strict": 0, "no-extra-semi": 1, @@ -32,6 +30,7 @@ "react/jsx-uses-react": 1 }, "globals": { - "SyntheticInputEvent": false + "SyntheticInputEvent": false, + "SyntheticKeyboardEvent": false } } diff --git a/common/actions/wallet.js b/common/actions/wallet.js new file mode 100644 index 00000000..656c0ba1 --- /dev/null +++ b/common/actions/wallet.js @@ -0,0 +1,29 @@ +// @flow +import type { PrivateKeyUnlockParams } from 'libs/wallet/privkey'; +import BaseWallet from 'libs/wallet/base'; + +export type UnlockPrivateKeyAction = { + type: 'WALLET_UNLOCK_PRIVATE_KEY', + payload: PrivateKeyUnlockParams +}; + +export type SaveWalletAction = { + type: 'WALLET_SAVE', + payload: BaseWallet +}; + +export type WalletAction = UnlockPrivateKeyAction | SaveWalletAction; + +export function unlockPrivateKey(value: PrivateKeyUnlockParams): UnlockPrivateKeyAction { + return { + type: 'WALLET_UNLOCK_PRIVATE_KEY', + payload: value + }; +} + +export function saveWallet(value: BaseWallet): SaveWalletAction { + return { + type: 'WALLET_SAVE', + payload: value + }; +} diff --git a/common/containers/Tabs/WalletDecrypt/KeystoreDecrypt/index.jsx b/common/components/WalletDecrypt/Keystore.jsx similarity index 100% rename from common/containers/Tabs/WalletDecrypt/KeystoreDecrypt/index.jsx rename to common/components/WalletDecrypt/Keystore.jsx diff --git a/common/containers/Tabs/WalletDecrypt/LedgerNanoSDecrypt/index.jsx b/common/components/WalletDecrypt/LedgerNano.jsx similarity index 100% rename from common/containers/Tabs/WalletDecrypt/LedgerNanoSDecrypt/index.jsx rename to common/components/WalletDecrypt/LedgerNano.jsx diff --git a/common/containers/Tabs/WalletDecrypt/MnemonicDecrypt/index.jsx b/common/components/WalletDecrypt/Mnemonic.jsx similarity index 100% rename from common/containers/Tabs/WalletDecrypt/MnemonicDecrypt/index.jsx rename to common/components/WalletDecrypt/Mnemonic.jsx diff --git a/common/components/WalletDecrypt/PrivateKey.jsx b/common/components/WalletDecrypt/PrivateKey.jsx new file mode 100644 index 00000000..c8cd8e98 --- /dev/null +++ b/common/components/WalletDecrypt/PrivateKey.jsx @@ -0,0 +1,95 @@ +// @flow +import React, { Component } from 'react'; +import translate from 'translations'; +import { isValidPrivKey } from 'libs/validators'; +import type { PrivateKeyUnlockParams } from 'libs/wallet/privkey'; + +export type PrivateKeyValue = PrivateKeyUnlockParams & { + valid: boolean +}; + +function fixPkey(key) { + if (key.indexOf('0x') === 0) { + return key.slice(2); + } + return key; +} + +export default class PrivateKeyDecrypt extends Component { + props: { + value: PrivateKeyUnlockParams, + onChange: (value: PrivateKeyUnlockParams) => void, + onUnlock: () => void + }; + + render() { + const { key, password } = this.props.value; + const fixedPkey = fixPkey(key); + const isValid = isValidPrivKey(fixedPkey.length); + const isPassRequired = fixedPkey.length > 64; + + return ( +
+
+

+ {translate('ADD_Radio_3')} +

+
+