diff --git a/.travis.yml b/.travis.yml index 0b22ddef..3224ba73 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,31 +35,21 @@ before_install: sh -e /etc/init.d/xvfb start # uncomment once integration tests are included in CI # docker pull dternyak/eth-priv-to-addr:latest - sudo apt-get install libusb-1.0 + sudo apt-get install libusb-1.0 fi - + install: - yarn --silent -script: - - | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - npm run prettier:diff - npm run test:coverage -- --maxWorkers=2 - npm run report-coverage - npm run tslint - npm run tscheck - npm run freezer - npm run freezer:validate - fi +before_script: + - chmod +x ./travis-scripts/test-{linux,osx}.sh + +script: + - ./travis-scripts/test-linux.sh + - ./travis-scripts/test-osx.sh - - | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - npm run build:electron - ls -la dist/electron-builds - fi notifications: email: on_success: never - on_failure: never + on_failure: never \ No newline at end of file diff --git a/README.md b/README.md index d48875ee..1d94e430 100644 --- a/README.md +++ b/README.md @@ -5,40 +5,52 @@ * **Just looking to download?** Grab our [latest release](https://github.com/MyCryptoHQ/MyCrypto/releases). * **Looking for the old site?** Check out [https://legacy.mycrypto.com](https://legacy.mycrypto.com) or the source at [MyCryptoHQ/mycrypto.com](https://github.com/MyCryptoHQ/mycrypto.com) +## Requirements + +* Node 8.9.4\* +* Yarn >= 1.7.0\*\* +* Python 2.7.X\*\*\* + +\*Higher versions should work fun, but may cause inconsistencies. It's suggested you run 8.9.4 using `nvm`. +
+**npm is NOT supported for package management. MyCrypto uses yarn.lock to ensure sub-dependency versions are pinned, so yarn is required to install node_modules +
+\***Python 3 is **not** supported, since our dependencies use `node-gyp`. + ## Running the App -This codebase targets Node 8.9.4 (LTS). After `npm install`ing all dependencies (You may be required to install additional system dependencies, due to some node modules relying on them) you can run various commands depending on what you want to do: +After `yarn`ing all dependencies you can run various commands depending on what you want to do: #### Development ```bash # run app in dev mode in browser, rebuild on file changes -npm run dev +yarn dev ``` ```bash # run app in dev mode in electron, rebuild on file changes -npm run dev:electron +yarn dev:electron ``` #### Build Releases ```bash # builds the production server app -npm run build +yarn build ``` ```bash # builds the downloadable version of the site -npm run build:downloadable +yarn build:downloadable ``` ```bash # builds the electron apps -npm run build:electron +yarn build:electron # builds only one OS's electron app -npm run build:electron:(osx|linux|windows) +yarn build:electron:(osx|linux|windows) ``` All of these builds are output to a folder in `dist/`. @@ -47,26 +59,26 @@ All of these builds are output to a folder in `dist/`. ```bash # run unit tests with Jest -npm run test +yarn test ``` #### Integration Tests: ```bash # run integration tests with Jest -npm run test:int +yarn test:int ``` #### Dev (HTTPS): Some parts of the site, such as the Ledger wallet, require an HTTPS environment to work. To develop on HTTPS, do the following: -1. Create your own SSL Certificate (Heroku has a [nice guide here](https://devcenter.heroku.com/articles/ssl-certificate-self)) -2. Move the `.key` and `.crt` files into `webpack_config/server.*` -3. Run the following command: +1. Create your own SSL Certificate (Heroku has a [nice guide here](https://devcenter.heroku.com/articles/ssl-certificate-self)) +2. Move the `.key` and `.crt` files into `webpack_config/server.*` +3. Run the following command: ```bash -npm run dev:https +yarn dev:https ``` #### Address Derivation Checker: @@ -79,20 +91,20 @@ To test for correct address derivation, the address derivation checker uses mult ##### The derivation checker utility assumes that you have: -1. Docker installed/available -2. [dternyak/eth-priv-to-addr](https://hub.docker.com/r/dternyak/eth-priv-to-addr/) pulled from DockerHub +1. Docker installed/available +2. [dternyak/eth-priv-to-addr](https://hub.docker.com/r/dternyak/eth-priv-to-addr/) pulled from DockerHub ##### Docker setup instructions: -1. Install docker (on macOS, [Docker for Mac](https://docs.docker.com/docker-for-mac/) is suggested) -2. `docker pull dternyak/eth-priv-to-addr` +1. Install docker (on macOS, [Docker for Mac](https://docs.docker.com/docker-for-mac/) is suggested) +2. `docker pull dternyak/eth-priv-to-addr` ##### Run Derivation Checker The derivation checker utility runs as part of the integration test suite. ```bash -npm run test:int +yarn test:int ``` ## Folder structure: @@ -134,4 +146,3 @@ npm run test:int Cross browser testing and debugging provided by the very lovely team at BrowserStack. - diff --git a/common/Root.tsx b/common/Root.tsx index 59dba1a1..0b91cede 100644 --- a/common/Root.tsx +++ b/common/Root.tsx @@ -1,6 +1,11 @@ import React, { Component } from 'react'; +import { Store } from 'redux'; import { Provider, connect } from 'react-redux'; -import { withRouter, Switch, Redirect, HashRouter, Route, BrowserRouter } from 'react-router-dom'; +import { withRouter, Switch, HashRouter, Route, BrowserRouter } from 'react-router-dom'; + +import { AppState } from 'features/reducers'; +import { getNetworkUnit } from 'features/config'; +import { transactionMetaActions } from 'features/transaction'; // Components import Contracts from 'containers/Tabs/Contracts'; import ENS from 'containers/Tabs/ENS'; @@ -18,14 +23,9 @@ import QrSignerModal from 'containers/QrSignerModal'; import OnboardModal from 'containers/OnboardModal'; import WelcomeModal from 'components/WelcomeModal'; import NewAppReleaseModal from 'components/NewAppReleaseModal'; -import { Store } from 'redux'; -import { pollOfflineStatus, TPollOfflineStatus } from 'actions/config'; -import { AppState } from 'reducers'; import { RouteNotFound } from 'components/RouteNotFound'; import { RedirectWithQuery } from 'components/RedirectWithQuery'; import 'what-input'; -import { setUnitMeta, TSetUnitMeta } from 'actions/transaction'; -import { getNetworkUnit } from 'selectors/config'; interface OwnProps { store: Store; @@ -36,8 +36,7 @@ interface StateProps { } interface DispatchProps { - pollOfflineStatus: TPollOfflineStatus; - setUnitMeta: TSetUnitMeta; + setUnitMeta: transactionMetaActions.TSetUnitMeta; } type Props = OwnProps & StateProps & DispatchProps; @@ -52,7 +51,6 @@ class RootClass extends Component { }; public componentDidMount() { - this.props.pollOfflineStatus(); this.props.setUnitMeta(this.props.networkUnit); this.addBodyClasses(); } @@ -80,7 +78,6 @@ class RootClass extends Component { const routes = ( - @@ -90,6 +87,7 @@ class RootClass extends Component { + @@ -190,6 +188,5 @@ const mapStateToProps = (state: AppState) => { }; export default connect(mapStateToProps, { - pollOfflineStatus, - setUnitMeta + setUnitMeta: transactionMetaActions.setUnitMeta })(RootClass); diff --git a/common/actions/addressBook/actionCreators.ts b/common/actions/addressBook/actionCreators.ts deleted file mode 100644 index 72682775..00000000 --- a/common/actions/addressBook/actionCreators.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { TypeKeys } from './constants'; -import { - AddressLabel, - AddressLabelEntry, - SetAddressLabel, - ClearAddressLabel, - SetAddressLabelEntry, - ChangeAddressLabelEntry, - SaveAddressLabelEntry, - ClearAddressLabelEntry, - RemoveAddressLabelEntry -} from './actionTypes'; - -export type TSetAddressLabel = typeof setAddressLabel; -export function setAddressLabel(payload: AddressLabel): SetAddressLabel { - return { - type: TypeKeys.SET_ADDRESS_LABEL, - payload - }; -} - -export type TClearAddressLabel = typeof clearAddressLabel; -export function clearAddressLabel(payload: string): ClearAddressLabel { - return { - type: TypeKeys.CLEAR_ADDRESS_LABEL, - payload - }; -} - -export type TSetAddressLabelEntry = typeof setAddressLabelEntry; -export function setAddressLabelEntry(payload: AddressLabelEntry): SetAddressLabelEntry { - return { - type: TypeKeys.SET_ADDRESS_LABEL_ENTRY, - payload - }; -} - -export type TChangeAddressLabelEntry = typeof changeAddressLabelEntry; -export function changeAddressLabelEntry(payload: AddressLabelEntry): ChangeAddressLabelEntry { - return { - type: TypeKeys.CHANGE_ADDRESS_LABEL_ENTRY, - payload - }; -} - -export type TSaveAddressLabelEntry = typeof saveAddressLabelEntry; -export function saveAddressLabelEntry(payload: string): SaveAddressLabelEntry { - return { - type: TypeKeys.SAVE_ADDRESS_LABEL_ENTRY, - payload - }; -} - -export type TClearAddressLabelEntry = typeof clearAddressLabelEntry; -export function clearAddressLabelEntry(payload: string): ClearAddressLabelEntry { - return { - type: TypeKeys.CLEAR_ADDRESS_LABEL_ENTRY, - payload - }; -} - -export type TRemoveAddressLabelEntry = typeof removeAddressLabelEntry; -export function removeAddressLabelEntry(payload: string): RemoveAddressLabelEntry { - return { - type: TypeKeys.REMOVE_ADDRESS_LABEL_ENTRY, - payload - }; -} diff --git a/common/actions/addressBook/constants.ts b/common/actions/addressBook/constants.ts deleted file mode 100644 index 604a4c89..00000000 --- a/common/actions/addressBook/constants.ts +++ /dev/null @@ -1,9 +0,0 @@ -export enum TypeKeys { - SET_ADDRESS_LABEL = 'SET_ADDRESS_LABEL', - CLEAR_ADDRESS_LABEL = 'CLEAR_ADDRESS_LABEL', - SET_ADDRESS_LABEL_ENTRY = 'SET_ADDRESS_LABEL_TEMPORARY_ENTRY', - CHANGE_ADDRESS_LABEL_ENTRY = 'CHANGE_ADDRESS_LABEL_ENTRY', - SAVE_ADDRESS_LABEL_ENTRY = 'SAVE_ADDRESS_LABEL_ENTRY', - CLEAR_ADDRESS_LABEL_ENTRY = 'CLEAR_ADDRESS_LABEL_ENTRY', - REMOVE_ADDRESS_LABEL_ENTRY = 'REMOVE_ADDRESS_LABEL_ENTRY' -} diff --git a/common/actions/addressBook/index.ts b/common/actions/addressBook/index.ts deleted file mode 100644 index 5a707547..00000000 --- a/common/actions/addressBook/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './actionTypes'; -export * from './actionCreators'; -export * from './constants'; diff --git a/common/actions/config/actionCreators.ts b/common/actions/config/actionCreators.ts deleted file mode 100644 index c1e6c26a..00000000 --- a/common/actions/config/actionCreators.ts +++ /dev/null @@ -1,153 +0,0 @@ -import * as interfaces from './actionTypes'; -import { TypeKeys } from './constants'; - -export function setOnline(): interfaces.SetOnlineAction { - return { - type: TypeKeys.CONFIG_SET_ONLINE - }; -} - -export function setOffline(): interfaces.SetOfflineAction { - return { - type: TypeKeys.CONFIG_SET_OFFLINE - }; -} - -export type TToggleAutoGasLimit = typeof toggleAutoGasLimit; -export function toggleAutoGasLimit(): interfaces.ToggleAutoGasLimitAction { - return { - type: TypeKeys.CONFIG_TOGGLE_AUTO_GAS_LIMIT - }; -} - -export type TChangeLanguage = typeof changeLanguage; -export function changeLanguage(sign: string): interfaces.ChangeLanguageAction { - return { - type: TypeKeys.CONFIG_LANGUAGE_CHANGE, - payload: sign - }; -} - -export type TPollOfflineStatus = typeof pollOfflineStatus; -export function pollOfflineStatus(): interfaces.PollOfflineStatus { - return { - type: TypeKeys.CONFIG_POLL_OFFLINE_STATUS - }; -} - -export type TChangeNodeRequested = typeof changeNodeRequested; -export function changeNodeRequested(payload: string): interfaces.ChangeNodeRequestedAction { - return { - type: TypeKeys.CONFIG_CHANGE_NODE_REQUESTED, - payload - }; -} - -export type TChangeNodeSucceded = typeof changeNodeSucceeded; -export function changeNodeSucceeded( - payload: interfaces.ChangeNodeSucceededAction['payload'] -): interfaces.ChangeNodeSucceededAction { - return { - type: TypeKeys.CONFIG_CHANGE_NODE_SUCCEEDED, - payload - }; -} - -export type TChangeNodeFailed = typeof changeNodeFailed; -export function changeNodeFailed(): interfaces.ChangeNodeFailedAction { - return { - type: TypeKeys.CONFIG_CHANGE_NODE_FAILED - }; -} - -export type TChangeNodeRequestedOneTime = typeof changeNodeRequestedOneTime; -export function changeNodeRequestedOneTime( - payload: string -): interfaces.ChangeNodeRequestedOneTimeAction { - return { - type: TypeKeys.CONFIG_CHANGE_NODE_REQUESTED_ONETIME, - payload - }; -} - -export type TChangeNodeForce = typeof changeNodeForce; -export function changeNodeForce(payload: string): interfaces.ChangeNodeForceAction { - return { - type: TypeKeys.CONFIG_CHANGE_NODE_FORCE, - payload - }; -} - -export type TChangeNetworkRequested = typeof changeNetworkRequested; -export function changeNetworkRequested( - payload: interfaces.ChangeNetworkRequestedAction['payload'] -): interfaces.ChangeNetworkRequestedAction { - return { - type: TypeKeys.CONFIG_CHANGE_NETWORK_REQUESTED, - payload - }; -} - -export type TAddCustomNode = typeof addCustomNode; -export function addCustomNode( - payload: interfaces.AddCustomNodeAction['payload'] -): interfaces.AddCustomNodeAction { - return { - type: TypeKeys.CONFIG_ADD_CUSTOM_NODE, - payload - }; -} - -export type TRemoveCustomNode = typeof removeCustomNode; -export function removeCustomNode( - payload: interfaces.RemoveCustomNodeAction['payload'] -): interfaces.RemoveCustomNodeAction { - return { - type: TypeKeys.CONFIG_REMOVE_CUSTOM_NODE, - payload - }; -} - -export type TAddCustomNetwork = typeof addCustomNetwork; -export function addCustomNetwork( - payload: interfaces.AddCustomNetworkAction['payload'] -): interfaces.AddCustomNetworkAction { - return { - type: TypeKeys.CONFIG_ADD_CUSTOM_NETWORK, - payload - }; -} - -export type TRemoveCustomNetwork = typeof removeCustomNetwork; -export function removeCustomNetwork( - payload: interfaces.RemoveCustomNetworkAction['payload'] -): interfaces.RemoveCustomNetworkAction { - return { - type: TypeKeys.CONFIG_REMOVE_CUSTOM_NETWORK, - payload - }; -} - -export type TSetLatestBlock = typeof setLatestBlock; -export function setLatestBlock(payload: string): interfaces.SetLatestBlockAction { - return { - type: TypeKeys.CONFIG_SET_LATEST_BLOCK, - payload - }; -} - -export function web3SetNode( - payload: interfaces.Web3setNodeAction['payload'] -): interfaces.Web3setNodeAction { - return { - type: TypeKeys.CONFIG_NODE_WEB3_SET, - payload - }; -} - -export type TWeb3UnsetNode = typeof web3UnsetNode; -export function web3UnsetNode(): interfaces.Web3UnsetNodeAction { - return { - type: TypeKeys.CONFIG_NODE_WEB3_UNSET - }; -} diff --git a/common/actions/config/actionTypes.ts b/common/actions/config/actionTypes.ts deleted file mode 100644 index bd2c11a1..00000000 --- a/common/actions/config/actionTypes.ts +++ /dev/null @@ -1,127 +0,0 @@ -import { TypeKeys } from './constants'; -import { CustomNodeConfig, StaticNodeConfig } from 'types/node'; -import { CustomNetworkConfig } from 'types/network'; - -export interface SetOnlineAction { - type: TypeKeys.CONFIG_SET_ONLINE; -} - -export interface SetOfflineAction { - type: TypeKeys.CONFIG_SET_OFFLINE; -} - -export interface ToggleAutoGasLimitAction { - type: TypeKeys.CONFIG_TOGGLE_AUTO_GAS_LIMIT; -} - -/*** Change Language ***/ -export interface ChangeLanguageAction { - type: TypeKeys.CONFIG_LANGUAGE_CHANGE; - payload: string; -} - -/*** Poll offline status ***/ -export interface PollOfflineStatus { - type: TypeKeys.CONFIG_POLL_OFFLINE_STATUS; -} - -/*** Change Node Requested ***/ -export interface ChangeNodeRequestedAction { - type: TypeKeys.CONFIG_CHANGE_NODE_REQUESTED; - payload: string; -} - -/*** Change Node Succeeded ***/ -export interface ChangeNodeSucceededAction { - type: TypeKeys.CONFIG_CHANGE_NODE_SUCCEEDED; - payload: { - nodeId: string; - networkId: string; - }; -} - -/*** Change Node Failed ***/ -export interface ChangeNodeFailedAction { - type: TypeKeys.CONFIG_CHANGE_NODE_FAILED; -} - -/*** Change Node Onetime ***/ -export interface ChangeNodeRequestedOneTimeAction { - type: TypeKeys.CONFIG_CHANGE_NODE_REQUESTED_ONETIME; - payload: string; -} - -/*** Force Change Node ***/ -export interface ChangeNodeForceAction { - type: TypeKeys.CONFIG_CHANGE_NODE_FORCE; - payload: string; -} - -/*** Change Network Intent ***/ -export interface ChangeNetworkRequestedAction { - type: TypeKeys.CONFIG_CHANGE_NETWORK_REQUESTED; - payload: string; -} - -/*** Add Custom Node ***/ -export interface AddCustomNodeAction { - type: TypeKeys.CONFIG_ADD_CUSTOM_NODE; - payload: CustomNodeConfig; -} - -/*** Remove Custom Node ***/ -export interface RemoveCustomNodeAction { - type: TypeKeys.CONFIG_REMOVE_CUSTOM_NODE; - payload: string; -} - -/*** Add Custom Network ***/ -export interface AddCustomNetworkAction { - type: TypeKeys.CONFIG_ADD_CUSTOM_NETWORK; - payload: CustomNetworkConfig; -} - -/*** Remove Custom Network ***/ -export interface RemoveCustomNetworkAction { - type: TypeKeys.CONFIG_REMOVE_CUSTOM_NETWORK; - payload: string; -} - -/*** Set Latest Block ***/ -export interface SetLatestBlockAction { - type: TypeKeys.CONFIG_SET_LATEST_BLOCK; - payload: string; -} - -/*** Unset Web3 as a Node ***/ -export interface Web3UnsetNodeAction { - type: TypeKeys.CONFIG_NODE_WEB3_UNSET; -} - -/*** Set Web3 as a Node ***/ -export interface Web3setNodeAction { - type: TypeKeys.CONFIG_NODE_WEB3_SET; - payload: { id: 'web3'; config: StaticNodeConfig }; -} - -export type CustomNetworkAction = AddCustomNetworkAction | RemoveCustomNetworkAction; - -export type CustomNodeAction = AddCustomNodeAction | RemoveCustomNodeAction; - -export type NodeAction = - | ChangeNodeSucceededAction - | ChangeNodeRequestedAction - | ChangeNodeFailedAction - | Web3UnsetNodeAction - | Web3setNodeAction; - -export type MetaAction = - | ChangeLanguageAction - | SetOnlineAction - | SetOfflineAction - | ToggleAutoGasLimitAction - | PollOfflineStatus - | SetLatestBlockAction; - -/*** Union Type ***/ -export type ConfigAction = CustomNetworkAction | CustomNodeAction | NodeAction | MetaAction; diff --git a/common/actions/config/constants.ts b/common/actions/config/constants.ts deleted file mode 100644 index 7a720c6c..00000000 --- a/common/actions/config/constants.ts +++ /dev/null @@ -1,26 +0,0 @@ -export enum TypeKeys { - CONFIG_LANGUAGE_CHANGE = 'CONFIG_LANGUAGE_CHANGE', - - CONFIG_SET_ONLINE = 'CONFIG_SET_ONLINE', - CONFIG_SET_OFFLINE = 'CONFIG_SET_OFFLINE', - - CONFIG_TOGGLE_OFFLINE = 'CONFIG_TOGGLE_OFFLINE', - CONFIG_TOGGLE_AUTO_GAS_LIMIT = 'CONFIG_TOGGLE_AUTO_GAS_LIMIT', - CONFIG_POLL_OFFLINE_STATUS = 'CONFIG_POLL_OFFLINE_STATUS', - CONFIG_SET_LATEST_BLOCK = 'CONFIG_SET_LATEST_BLOCK', - - CONFIG_NODE_WEB3_SET = 'CONFIG_NODE_WEB3_SET', - CONFIG_NODE_WEB3_UNSET = 'CONFIG_NODE_WEB3_UNSET', - CONFIG_CHANGE_NODE_REQUESTED = 'CONFIG_CHANGE_NODE_REQUESTED', - CONFIG_CHANGE_NODE_SUCCEEDED = 'CONFIG_CHANGE_NODE_SUCCEEDED', - CONFIG_CHANGE_NODE_FAILED = 'CONFIG_CHANGE_NODE_FAILED', - CONFIG_CHANGE_NODE_REQUESTED_ONETIME = 'CONFIG_CHANGE_NODE_REQUESTED_ONETIME', - CONFIG_CHANGE_NODE_FORCE = 'CONFIG_CHANGE_NODE_FORCE', - CONFIG_CHANGE_NETWORK_REQUESTED = 'CONFIG_CHANGE_NETWORK_REQUESTED', - - CONFIG_ADD_CUSTOM_NODE = 'CONFIG_ADD_CUSTOM_NODE', - CONFIG_REMOVE_CUSTOM_NODE = 'CONFIG_REMOVE_CUSTOM_NODE', - - CONFIG_ADD_CUSTOM_NETWORK = 'CONFIG_ADD_CUSTOM_NETWORK', - CONFIG_REMOVE_CUSTOM_NETWORK = 'CONFIG_REMOVE_CUSTOM_NETWORK' -} diff --git a/common/actions/config/index.ts b/common/actions/config/index.ts deleted file mode 100644 index 51fcd517..00000000 --- a/common/actions/config/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './actionCreators'; -export * from './actionTypes'; -export * from './constants'; diff --git a/common/actions/customTokens/actionCreators.ts b/common/actions/customTokens/actionCreators.ts deleted file mode 100644 index 72d5246d..00000000 --- a/common/actions/customTokens/actionCreators.ts +++ /dev/null @@ -1,20 +0,0 @@ -import * as interfaces from './actionTypes'; -import { TypeKeys } from './constants'; -import { Token } from 'types/network'; - -export type TAddCustomToken = typeof addCustomToken; -export function addCustomToken(payload: Token): interfaces.AddCustomTokenAction { - return { - type: TypeKeys.CUSTOM_TOKEN_ADD, - payload - }; -} - -export type TRemoveCustomToken = typeof removeCustomToken; - -export function removeCustomToken(payload: string): interfaces.RemoveCustomTokenAction { - return { - type: TypeKeys.CUSTOM_TOKEN_REMOVE, - payload - }; -} diff --git a/common/actions/customTokens/constants.ts b/common/actions/customTokens/constants.ts deleted file mode 100644 index 7a5dcaa3..00000000 --- a/common/actions/customTokens/constants.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum TypeKeys { - CUSTOM_TOKEN_ADD = 'CUSTOM_TOKEN_ADD', - CUSTOM_TOKEN_REMOVE = 'CUSTOM_TOKEN_REMOVE' -} diff --git a/common/actions/customTokens/index.ts b/common/actions/customTokens/index.ts deleted file mode 100644 index 51fcd517..00000000 --- a/common/actions/customTokens/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './actionCreators'; -export * from './actionTypes'; -export * from './constants'; diff --git a/common/actions/deterministicWallets/actionCreators.ts b/common/actions/deterministicWallets/actionCreators.ts deleted file mode 100644 index 396cd2d7..00000000 --- a/common/actions/deterministicWallets/actionCreators.ts +++ /dev/null @@ -1,43 +0,0 @@ -import * as interfaces from './actionTypes'; -import { TypeKeys } from './constants'; -export function getDeterministicWallets( - args: interfaces.GetDeterministicWalletsArgs -): interfaces.GetDeterministicWalletsAction { - const { seed, dPath, publicKey, chainCode, limit, offset } = args; - return { - type: TypeKeys.DW_GET_WALLETS, - payload: { - seed, - dPath, - publicKey, - chainCode, - limit: limit || 5, - offset: offset || 0 - } - }; -} - -export function setDeterministicWallets( - wallets: interfaces.DeterministicWalletData[] -): interfaces.SetDeterministicWalletsAction { - return { - type: TypeKeys.DW_SET_WALLETS, - payload: wallets - }; -} - -export function setDesiredToken(token: string | undefined): interfaces.SetDesiredTokenAction { - return { - type: TypeKeys.DW_SET_DESIRED_TOKEN, - payload: token - }; -} - -export function updateDeterministicWallet( - args: interfaces.UpdateDeterministicWalletArgs -): interfaces.UpdateDeterministicWalletAction { - return { - type: TypeKeys.DW_UPDATE_WALLET, - payload: args - }; -} diff --git a/common/actions/deterministicWallets/constants.ts b/common/actions/deterministicWallets/constants.ts deleted file mode 100644 index b7e566a5..00000000 --- a/common/actions/deterministicWallets/constants.ts +++ /dev/null @@ -1,6 +0,0 @@ -export enum TypeKeys { - DW_GET_WALLETS = 'DW_GET_WALLETS', - DW_SET_WALLETS = 'DW_SET_WALLETS', - DW_SET_DESIRED_TOKEN = 'DW_SET_DESIRED_TOKEN', - DW_UPDATE_WALLET = 'DW_UPDATE_WALLET' -} diff --git a/common/actions/deterministicWallets/index.ts b/common/actions/deterministicWallets/index.ts deleted file mode 100644 index 2608a18e..00000000 --- a/common/actions/deterministicWallets/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './actionTypes'; -export * from './actionCreators'; diff --git a/common/actions/ens/actionCreators/index.ts b/common/actions/ens/actionCreators/index.ts deleted file mode 100644 index 9ea71985..00000000 --- a/common/actions/ens/actionCreators/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './resolveDomain'; diff --git a/common/actions/ens/actionCreators/resolveDomain.ts b/common/actions/ens/actionCreators/resolveDomain.ts deleted file mode 100644 index c402ed24..00000000 --- a/common/actions/ens/actionCreators/resolveDomain.ts +++ /dev/null @@ -1,35 +0,0 @@ -import * as ActionTypes from '../actionTypes'; -import { TypeKeys } from '../constants'; -import { DomainRequest } from 'libs/ens'; -import { ResolveDomainCached } from 'actions/ens'; - -export type TResolveDomainRequested = typeof resolveDomainRequested; -export const resolveDomainRequested = (domain: string): ActionTypes.ResolveDomainRequested => ({ - type: TypeKeys.ENS_RESOLVE_DOMAIN_REQUESTED, - payload: { domain } -}); - -export const resolveDomainCached = ( - payload: ResolveDomainCached['payload'] -): ResolveDomainCached => ({ - type: TypeKeys.ENS_RESOLVE_DOMAIN_CACHED, - payload -}); - -export type TResolveDomainSucceeded = typeof resolveDomainSucceeded; -export const resolveDomainSucceeded = ( - domain: string, - domainData: DomainRequest -): ActionTypes.ResolveDomainSucceeded => ({ - type: TypeKeys.ENS_RESOLVE_DOMAIN_SUCCEEDED, - payload: { domain, domainData } -}); - -export type TResolveDomainFailed = typeof resolveDomainFailed; -export const resolveDomainFailed = ( - domain: string, - error: Error -): ActionTypes.ResolveDomainFailed => ({ - type: TypeKeys.ENS_RESOLVE_DOMAIN_FAILED, - payload: { domain, error } -}); diff --git a/common/actions/ens/actionTypes/actionTypes.ts b/common/actions/ens/actionTypes/actionTypes.ts deleted file mode 100644 index e9d035f9..00000000 --- a/common/actions/ens/actionTypes/actionTypes.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { ResolveDomainAction } from './resolveDomain'; -export * from './resolveDomain'; - -export type EnsAction = ResolveDomainAction; diff --git a/common/actions/ens/actionTypes/index.ts b/common/actions/ens/actionTypes/index.ts deleted file mode 100644 index 3eb256de..00000000 --- a/common/actions/ens/actionTypes/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './actionTypes'; diff --git a/common/actions/ens/actionTypes/resolveDomain.ts b/common/actions/ens/actionTypes/resolveDomain.ts deleted file mode 100644 index aab2d357..00000000 --- a/common/actions/ens/actionTypes/resolveDomain.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { TypeKeys } from '../constants'; -import { DomainRequest } from 'libs/ens'; - -export interface ResolveDomainRequested { - type: TypeKeys.ENS_RESOLVE_DOMAIN_REQUESTED; - payload: { domain: string }; -} - -export interface ResolveDomainSucceeded { - type: TypeKeys.ENS_RESOLVE_DOMAIN_SUCCEEDED; - payload: { domain: string; domainData: DomainRequest }; -} - -export interface ResolveDomainCached { - type: TypeKeys.ENS_RESOLVE_DOMAIN_CACHED; - payload: { domain: string }; -} - -export interface ResolveDomainFailed { - type: TypeKeys.ENS_RESOLVE_DOMAIN_FAILED; - payload: { domain: string; error: Error }; -} - -export type ResolveDomainAction = - | ResolveDomainRequested - | ResolveDomainSucceeded - | ResolveDomainFailed - | ResolveDomainCached; diff --git a/common/actions/ens/constants.ts b/common/actions/ens/constants.ts deleted file mode 100644 index fdab3be9..00000000 --- a/common/actions/ens/constants.ts +++ /dev/null @@ -1,6 +0,0 @@ -export enum TypeKeys { - ENS_RESOLVE_DOMAIN_REQUESTED = 'ENS_RESOLVE_DOMAIN_REQUESTED', - ENS_RESOLVE_DOMAIN_SUCCEEDED = 'ENS_RESOLVE_DOMAIN_SUCCEEDED', - ENS_RESOLVE_DOMAIN_FAILED = 'ENS_RESOLVE_DOMAIN_FAILED', - ENS_RESOLVE_DOMAIN_CACHED = 'ENS_RESOLVE_DOMAIN_CACHED' -} diff --git a/common/actions/ens/index.ts b/common/actions/ens/index.ts deleted file mode 100644 index fee14683..00000000 --- a/common/actions/ens/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './constants'; -export * from './actionTypes'; -export * from './actionCreators'; diff --git a/common/actions/gas/actionCreators.ts b/common/actions/gas/actionCreators.ts deleted file mode 100644 index c09b1bfe..00000000 --- a/common/actions/gas/actionCreators.ts +++ /dev/null @@ -1,19 +0,0 @@ -import * as interfaces from './actionTypes'; -import { TypeKeys } from './constants'; - -export type TFetchGasEstimates = typeof fetchGasEstimates; -export function fetchGasEstimates(): interfaces.FetchGasEstimatesAction { - return { - type: TypeKeys.GAS_FETCH_ESTIMATES - }; -} - -export type TSetGasEstimates = typeof setGasEstimates; -export function setGasEstimates( - payload: interfaces.SetGasEstimatesAction['payload'] -): interfaces.SetGasEstimatesAction { - return { - type: TypeKeys.GAS_SET_ESTIMATES, - payload - }; -} diff --git a/common/actions/gas/actionTypes.ts b/common/actions/gas/actionTypes.ts deleted file mode 100644 index a66b86c0..00000000 --- a/common/actions/gas/actionTypes.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { TypeKeys } from './constants'; -import { GasEstimates } from 'api/gas'; - -export interface FetchGasEstimatesAction { - type: TypeKeys.GAS_FETCH_ESTIMATES; -} - -export interface SetGasEstimatesAction { - type: TypeKeys.GAS_SET_ESTIMATES; - payload: GasEstimates; -} - -/*** Union Type ***/ -export type GasAction = FetchGasEstimatesAction | SetGasEstimatesAction; diff --git a/common/actions/gas/constants.ts b/common/actions/gas/constants.ts deleted file mode 100644 index 569bcb6b..00000000 --- a/common/actions/gas/constants.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum TypeKeys { - GAS_FETCH_ESTIMATES = 'GAS_FETCH_ESTIMATES', - GAS_SET_ESTIMATES = 'GAS_SET_ESTIMATES' -} diff --git a/common/actions/gas/index.ts b/common/actions/gas/index.ts deleted file mode 100644 index 51fcd517..00000000 --- a/common/actions/gas/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './actionCreators'; -export * from './actionTypes'; -export * from './constants'; diff --git a/common/actions/message/actionCreators.ts b/common/actions/message/actionCreators.ts deleted file mode 100644 index a71c5549..00000000 --- a/common/actions/message/actionCreators.ts +++ /dev/null @@ -1,28 +0,0 @@ -import * as interfaces from './actionTypes'; -import { TypeKeys } from './constants'; -import { ISignedMessage } from 'libs/signing'; - -export type TSignMessageRequested = typeof signMessageRequested; -export function signMessageRequested(payload: string): interfaces.SignMessageRequestedAction { - return { - type: TypeKeys.SIGN_MESSAGE_REQUESTED, - payload - }; -} - -export type TSignLocalMessageSucceeded = typeof signLocalMessageSucceeded; -export function signLocalMessageSucceeded( - payload: ISignedMessage -): interfaces.SignLocalMessageSucceededAction { - return { - type: TypeKeys.SIGN_LOCAL_MESSAGE_SUCCEEDED, - payload - }; -} - -export type TSignMessageFailed = typeof signMessageFailed; -export function signMessageFailed(): interfaces.SignMessageFailedAction { - return { - type: TypeKeys.SIGN_MESSAGE_FAILED - }; -} diff --git a/common/actions/message/constants.ts b/common/actions/message/constants.ts deleted file mode 100644 index 335bfdff..00000000 --- a/common/actions/message/constants.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum TypeKeys { - SIGN_MESSAGE_REQUESTED = 'SIGN_MESSAGE_REQUESTED', - SIGN_LOCAL_MESSAGE_SUCCEEDED = 'SIGN_LOCAL_MESSAGE_SUCCEEDED', - SIGN_MESSAGE_FAILED = 'SIGN_MESSAGE_FAILED' -} diff --git a/common/actions/message/index.ts b/common/actions/message/index.ts deleted file mode 100644 index d5122d97..00000000 --- a/common/actions/message/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './actionCreators'; -export * from './constants'; -export * from './actionTypes'; diff --git a/common/actions/notifications/actionCreators.ts b/common/actions/notifications/actionCreators.ts deleted file mode 100644 index 99949933..00000000 --- a/common/actions/notifications/actionCreators.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { ReactElement } from 'react'; -import * as types from './actionTypes'; -import { TypeKeys } from './constants'; - -export type TShowNotification = typeof showNotification; -export function showNotification( - level: types.NOTIFICATION_LEVEL = 'info', - msg: ReactElement | string, - duration?: number -): types.ShowNotificationAction { - return { - type: TypeKeys.SHOW_NOTIFICATION, - payload: { - level, - msg, - duration, - id: Math.random() - } - }; -} - -export type TCloseNotification = typeof closeNotification; -export function closeNotification(notification: types.Notification): types.CloseNotificationAction { - return { - type: TypeKeys.CLOSE_NOTIFICATION, - payload: notification - }; -} diff --git a/common/actions/notifications/actionTypes.ts b/common/actions/notifications/actionTypes.ts deleted file mode 100644 index 3a7377f1..00000000 --- a/common/actions/notifications/actionTypes.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { ReactElement } from 'react'; -import { TypeKeys } from './constants'; -/*** Shared types ***/ -export type NOTIFICATION_LEVEL = 'danger' | 'warning' | 'success' | 'info'; - -export interface Notification { - level: NOTIFICATION_LEVEL; - msg: ReactElement | string; - id: number; - duration?: number; -} - -/*** Close notification ***/ -export interface CloseNotificationAction { - type: TypeKeys.CLOSE_NOTIFICATION; - payload: Notification; -} - -/*** Show Notification ***/ -export interface ShowNotificationAction { - type: TypeKeys.SHOW_NOTIFICATION; - payload: Notification; -} - -/*** Union Type ***/ -export type NotificationsAction = ShowNotificationAction | CloseNotificationAction; diff --git a/common/actions/notifications/constants.ts b/common/actions/notifications/constants.ts deleted file mode 100644 index 8529f18e..00000000 --- a/common/actions/notifications/constants.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum TypeKeys { - SHOW_NOTIFICATION = 'SHOW_NOTIFICATION', - CLOSE_NOTIFICATION = 'CLOSE_NOTIFICATION' -} diff --git a/common/actions/notifications/index.ts b/common/actions/notifications/index.ts deleted file mode 100644 index 2608a18e..00000000 --- a/common/actions/notifications/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './actionTypes'; -export * from './actionCreators'; diff --git a/common/actions/onboardStatus/actionCreators.ts b/common/actions/onboardStatus/actionCreators.ts deleted file mode 100644 index fc0a40a9..00000000 --- a/common/actions/onboardStatus/actionCreators.ts +++ /dev/null @@ -1,31 +0,0 @@ -import * as interfaces from './actionTypes'; -import { TypeKeys } from './constants'; - -export type TStartOnboardSession = typeof startOnboardSession; -export function startOnboardSession(): interfaces.StartOnboardSessionAction { - return { - type: TypeKeys.START_ONBOARD_SESSION - }; -} - -export type TResumeSlide = typeof resumeSlide; -export function resumeSlide(slideNumber: number): interfaces.ResumeSlideAction { - return { - type: TypeKeys.RESUME_SLIDE, - slideNumber - }; -} - -export type TDecrementSlide = typeof decrementSlide; -export function decrementSlide(): interfaces.DecrementSlideAction { - return { - type: TypeKeys.DECREMENT_SLIDE - }; -} - -export type TIncrementSlide = typeof incrementSlide; -export function incrementSlide(): interfaces.IncrementSlideAction { - return { - type: TypeKeys.INCREMENT_SLIDE - }; -} diff --git a/common/actions/onboardStatus/actionTypes.ts b/common/actions/onboardStatus/actionTypes.ts deleted file mode 100644 index a2eae24b..00000000 --- a/common/actions/onboardStatus/actionTypes.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { TypeKeys } from './constants'; - -export interface StartOnboardSessionAction { - type: TypeKeys.START_ONBOARD_SESSION; -} - -export interface ResumeSlideAction { - type: TypeKeys.RESUME_SLIDE; - slideNumber: number; -} - -export interface DecrementSlideAction { - type: TypeKeys.DECREMENT_SLIDE; -} - -export interface IncrementSlideAction { - type: TypeKeys.INCREMENT_SLIDE; -} - -export type OnboardStatusAction = - | StartOnboardSessionAction - | ResumeSlideAction - | DecrementSlideAction - | IncrementSlideAction; diff --git a/common/actions/onboardStatus/constants.ts b/common/actions/onboardStatus/constants.ts deleted file mode 100644 index 859e539a..00000000 --- a/common/actions/onboardStatus/constants.ts +++ /dev/null @@ -1,6 +0,0 @@ -export enum TypeKeys { - START_ONBOARD_SESSION = 'START_ONBOARD_SESSION', - RESUME_SLIDE = 'RESUME_SLIDE', - DECREMENT_SLIDE = 'DECREMENT_SLIDE', - INCREMENT_SLIDE = 'INCREMENT_SLIDE' -} diff --git a/common/actions/onboardStatus/index.ts b/common/actions/onboardStatus/index.ts deleted file mode 100644 index 2608a18e..00000000 --- a/common/actions/onboardStatus/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './actionTypes'; -export * from './actionCreators'; diff --git a/common/actions/paritySigner/actionTypes.ts b/common/actions/paritySigner/actionTypes.ts deleted file mode 100644 index e5318006..00000000 --- a/common/actions/paritySigner/actionTypes.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { TypeKeys } from './constants'; - -export interface RequestTransactionSignatureAction { - type: TypeKeys.PARITY_SIGNER_REQUEST_TX_SIGNATURE; - payload: { - isMessage: false; - data: string; - from: string; - }; -} - -export interface RequestMessageSignatureAction { - type: TypeKeys.PARITY_SIGNER_REQUEST_MSG_SIGNATURE; - payload: { - isMessage: true; - data: string; - from: string; - }; -} - -export interface FinalizeSignatureAction { - type: TypeKeys.PARITY_SIGNER_FINALIZE_SIGNATURE; - payload: string | null; -} - -/*** Union Type ***/ -export type ParitySignerAction = - | RequestTransactionSignatureAction - | RequestMessageSignatureAction - | FinalizeSignatureAction; diff --git a/common/actions/paritySigner/constants.ts b/common/actions/paritySigner/constants.ts deleted file mode 100644 index e61fed3f..00000000 --- a/common/actions/paritySigner/constants.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum TypeKeys { - PARITY_SIGNER_REQUEST_TX_SIGNATURE = 'PARITY_SIGNER_REQUEST_TX_SIGNATURE', - PARITY_SIGNER_REQUEST_MSG_SIGNATURE = 'PARITY_SIGNER_REQUEST_MSG_SIGNATURE', - PARITY_SIGNER_FINALIZE_SIGNATURE = 'PARITY_SIGNER_FINALIZE_SIGNATURE' -} diff --git a/common/actions/paritySigner/index.ts b/common/actions/paritySigner/index.ts deleted file mode 100644 index fee14683..00000000 --- a/common/actions/paritySigner/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './constants'; -export * from './actionTypes'; -export * from './actionCreators'; diff --git a/common/actions/rates/actionCreators.ts b/common/actions/rates/actionCreators.ts deleted file mode 100644 index 22b82167..00000000 --- a/common/actions/rates/actionCreators.ts +++ /dev/null @@ -1,26 +0,0 @@ -import * as interfaces from './actionTypes'; -import { TypeKeys } from './constants'; -import { CCResponse } from 'api/rates'; - -export type TFetchCCRatesRequested = typeof fetchCCRatesRequested; -export function fetchCCRatesRequested(symbols: string[] = []): interfaces.FetchCCRatesRequested { - return { - type: TypeKeys.RATES_FETCH_CC_REQUESTED, - payload: symbols - }; -} - -export type TFetchCCRatesSucceeded = typeof fetchCCRatesSucceeded; -export function fetchCCRatesSucceeded(payload: CCResponse): interfaces.FetchCCRatesSucceeded { - return { - type: TypeKeys.RATES_FETCH_CC_SUCCEEDED, - payload - }; -} - -export type TFetchCCRatesFailed = typeof fetchCCRatesFailed; -export function fetchCCRatesFailed(): interfaces.FetchCCRatesFailed { - return { - type: TypeKeys.RATES_FETCH_CC_FAILED - }; -} diff --git a/common/actions/rates/actionTypes.ts b/common/actions/rates/actionTypes.ts deleted file mode 100644 index abd4d9eb..00000000 --- a/common/actions/rates/actionTypes.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { TypeKeys } from './constants'; -import { CCResponse } from 'api/rates'; - -export interface FetchCCRatesRequested { - type: TypeKeys.RATES_FETCH_CC_REQUESTED; - payload: string[]; -} - -/*** Set rates ***/ -export interface FetchCCRatesSucceeded { - type: TypeKeys.RATES_FETCH_CC_SUCCEEDED; - payload: CCResponse; -} - -export interface FetchCCRatesFailed { - type: TypeKeys.RATES_FETCH_CC_FAILED; -} - -/*** Union Type ***/ -export type RatesAction = FetchCCRatesRequested | FetchCCRatesSucceeded | FetchCCRatesFailed; diff --git a/common/actions/rates/constants.ts b/common/actions/rates/constants.ts deleted file mode 100644 index 419a1c30..00000000 --- a/common/actions/rates/constants.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum TypeKeys { - RATES_FETCH_CC_REQUESTED = 'RATES_FETCH_CC_REQUESTED', - RATES_FETCH_CC_FAILED = 'RATES_FETCH_CC_FAILED', - RATES_FETCH_CC_SUCCEEDED = 'RATES_FETCH_CC_SUCCEEDED' -} diff --git a/common/actions/rates/index.ts b/common/actions/rates/index.ts deleted file mode 100644 index 113dd69a..00000000 --- a/common/actions/rates/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './actionCreators'; -export * from './actionTypes'; diff --git a/common/actions/schedule/actionCreators/fields.ts b/common/actions/schedule/actionCreators/fields.ts deleted file mode 100644 index ab1cf3d4..00000000 --- a/common/actions/schedule/actionCreators/fields.ts +++ /dev/null @@ -1,117 +0,0 @@ -import { - SetTimeBountyFieldAction, - SetWindowSizeFieldAction, - SetWindowStartFieldAction, - SetScheduleTimestampFieldAction, - SetScheduleTypeAction, - SetSchedulingToggleAction, - SetScheduleTimezoneAction, - SetScheduleGasPriceFieldAction, - SetScheduleGasLimitFieldAction, - SetScheduleDepositFieldAction, - SetScheduleParamsValidityAction -} from '../actionTypes'; -import { TypeKeys } from 'actions/schedule/constants'; - -type TSetTimeBountyField = typeof setTimeBountyField; -const setTimeBountyField = ( - payload: SetTimeBountyFieldAction['payload'] -): SetTimeBountyFieldAction => ({ - type: TypeKeys.TIME_BOUNTY_FIELD_SET, - payload -}); - -type TSetWindowSizeField = typeof setWindowSizeField; -const setWindowSizeField = ( - payload: SetWindowSizeFieldAction['payload'] -): SetWindowSizeFieldAction => ({ - type: TypeKeys.WINDOW_SIZE_FIELD_SET, - payload -}); - -type TSetWindowStartField = typeof setWindowStartField; -const setWindowStartField = ( - payload: SetWindowStartFieldAction['payload'] -): SetWindowStartFieldAction => ({ - type: TypeKeys.WINDOW_START_FIELD_SET, - payload -}); - -type TSetScheduleTimestampField = typeof setScheduleTimestampField; -const setScheduleTimestampField = ( - payload: SetScheduleTimestampFieldAction['payload'] -): SetScheduleTimestampFieldAction => ({ - type: TypeKeys.SCHEDULE_TIMESTAMP_FIELD_SET, - payload -}); - -type TSetScheduleType = typeof setScheduleType; -const setScheduleType = (payload: SetScheduleTypeAction['payload']): SetScheduleTypeAction => ({ - type: TypeKeys.SCHEDULE_TYPE_SET, - payload -}); - -type TSetSchedulingToggle = typeof setSchedulingToggle; -const setSchedulingToggle = ( - payload: SetSchedulingToggleAction['payload'] -): SetSchedulingToggleAction => ({ - type: TypeKeys.SCHEDULING_TOGGLE_SET, - payload -}); - -type TSetScheduleTimezone = typeof setScheduleTimezone; -const setScheduleTimezone = ( - payload: SetScheduleTimezoneAction['payload'] -): SetScheduleTimezoneAction => ({ - type: TypeKeys.SCHEDULE_TIMEZONE_SET, - payload -}); - -type TSetScheduleGasPriceField = typeof setScheduleGasPriceField; -const setScheduleGasPriceField = (payload: SetScheduleGasPriceFieldAction['payload']) => ({ - type: TypeKeys.SCHEDULE_GAS_PRICE_FIELD_SET, - payload -}); - -type TSetScheduleGasLimitField = typeof setScheduleGasLimitField; -const setScheduleGasLimitField = (payload: SetScheduleGasLimitFieldAction['payload']) => ({ - type: TypeKeys.SCHEDULE_GAS_LIMIT_FIELD_SET, - payload -}); - -type TSetScheduleDepositField = typeof setScheduleDepositField; -const setScheduleDepositField = (payload: SetScheduleDepositFieldAction['payload']) => ({ - type: TypeKeys.SCHEDULE_DEPOSIT_FIELD_SET, - payload -}); - -type TSetScheduleParamsValidity = typeof setScheduleParamsValidity; -const setScheduleParamsValidity = (payload: SetScheduleParamsValidityAction['payload']) => ({ - type: TypeKeys.SCHEDULE_PARAMS_VALIDITY_SET, - payload -}); - -export { - TSetWindowSizeField, - TSetWindowStartField, - TSetTimeBountyField, - TSetScheduleTimestampField, - TSetScheduleType, - TSetSchedulingToggle, - TSetScheduleTimezone, - TSetScheduleGasPriceField, - TSetScheduleGasLimitField, - TSetScheduleDepositField, - TSetScheduleParamsValidity, - setTimeBountyField, - setWindowSizeField, - setWindowStartField, - setScheduleTimestampField, - setScheduleType, - setSchedulingToggle, - setScheduleTimezone, - setScheduleGasPriceField, - setScheduleGasLimitField, - setScheduleDepositField, - setScheduleParamsValidity -}; diff --git a/common/actions/schedule/actionCreators/index.ts b/common/actions/schedule/actionCreators/index.ts deleted file mode 100644 index a58fba82..00000000 --- a/common/actions/schedule/actionCreators/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './fields'; -export * from './scheduleTimestamp'; -export * from './scheduleType'; -export * from './schedulingToggle'; -export * from './timeBounty'; -export * from './windowSize'; -export * from './windowStart'; diff --git a/common/actions/schedule/actionCreators/scheduleTimestamp.ts b/common/actions/schedule/actionCreators/scheduleTimestamp.ts deleted file mode 100644 index caa0839c..00000000 --- a/common/actions/schedule/actionCreators/scheduleTimestamp.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { TypeKeys } from 'actions/schedule'; -import { - SetCurrentScheduleTimestampAction, - SetCurrentScheduleTimezoneAction -} from '../actionTypes/scheduleTimestamp'; - -export type TSetCurrentScheduleTimestamp = typeof setCurrentScheduleTimestamp; -export const setCurrentScheduleTimestamp = ( - payload: SetCurrentScheduleTimestampAction['payload'] -): SetCurrentScheduleTimestampAction => ({ - type: TypeKeys.CURRENT_SCHEDULE_TIMESTAMP_SET, - payload -}); - -export type TSetCurrentScheduleTimezone = typeof setCurrentScheduleTimezone; -export const setCurrentScheduleTimezone = ( - payload: SetCurrentScheduleTimezoneAction['payload'] -): SetCurrentScheduleTimezoneAction => ({ - type: TypeKeys.CURRENT_SCHEDULE_TIMEZONE_SET, - payload -}); diff --git a/common/actions/schedule/actionCreators/scheduleType.ts b/common/actions/schedule/actionCreators/scheduleType.ts deleted file mode 100644 index 9e5c78ed..00000000 --- a/common/actions/schedule/actionCreators/scheduleType.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { TypeKeys } from 'actions/schedule'; -import { SetCurrentScheduleTypeAction } from '../actionTypes/scheduleType'; - -export type TSetCurrentScheduleType = typeof setCurrentScheduleType; -export const setCurrentScheduleType = ( - payload: SetCurrentScheduleTypeAction['payload'] -): SetCurrentScheduleTypeAction => ({ - type: TypeKeys.CURRENT_SCHEDULE_TYPE, - payload -}); diff --git a/common/actions/schedule/actionCreators/schedulingToggle.ts b/common/actions/schedule/actionCreators/schedulingToggle.ts deleted file mode 100644 index 10c69a3b..00000000 --- a/common/actions/schedule/actionCreators/schedulingToggle.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { SetCurrentSchedulingToggleAction } from '../actionTypes/schedulingToggle'; -import { TypeKeys } from 'actions/schedule'; - -type TSetCurrentSchedulingToggle = typeof setCurrentSchedulingToggle; -const setCurrentSchedulingToggle = ( - payload: SetCurrentSchedulingToggleAction['payload'] -): SetCurrentSchedulingToggleAction => ({ - type: TypeKeys.CURRENT_SCHEDULING_TOGGLE, - payload -}); - -export { TSetCurrentSchedulingToggle, setCurrentSchedulingToggle }; diff --git a/common/actions/schedule/actionCreators/timeBounty.ts b/common/actions/schedule/actionCreators/timeBounty.ts deleted file mode 100644 index 8d138d81..00000000 --- a/common/actions/schedule/actionCreators/timeBounty.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { SetCurrentTimeBountyAction } from '../actionTypes/timeBounty'; -import { TypeKeys } from 'actions/schedule'; - -type TSetCurrentTimeBounty = typeof setCurrentTimeBounty; -const setCurrentTimeBounty = ( - payload: SetCurrentTimeBountyAction['payload'] -): SetCurrentTimeBountyAction => ({ - type: TypeKeys.CURRENT_TIME_BOUNTY_SET, - payload -}); - -export { setCurrentTimeBounty, TSetCurrentTimeBounty }; diff --git a/common/actions/schedule/actionCreators/windowSize.ts b/common/actions/schedule/actionCreators/windowSize.ts deleted file mode 100644 index 0c321801..00000000 --- a/common/actions/schedule/actionCreators/windowSize.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { SetCurrentWindowSizeAction } from '../actionTypes/windowSize'; -import { TypeKeys } from 'actions/schedule'; - -type TSetCurrentWindowSize = typeof setCurrentWindowSize; -const setCurrentWindowSize = ( - payload: SetCurrentWindowSizeAction['payload'] -): SetCurrentWindowSizeAction => ({ - type: TypeKeys.CURRENT_WINDOW_SIZE_SET, - payload -}); - -export { setCurrentWindowSize, TSetCurrentWindowSize }; diff --git a/common/actions/schedule/actionCreators/windowStart.ts b/common/actions/schedule/actionCreators/windowStart.ts deleted file mode 100644 index c22a6dcb..00000000 --- a/common/actions/schedule/actionCreators/windowStart.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { SetCurrentWindowStartAction } from '../actionTypes/windowStart'; -import { TypeKeys } from 'actions/schedule'; - -type TSetCurrentWindowStart = typeof setCurrentWindowStart; -const setCurrentWindowStart = ( - payload: SetCurrentWindowStartAction['payload'] -): SetCurrentWindowStartAction => ({ - type: TypeKeys.CURRENT_WINDOW_START_SET, - payload -}); - -export { setCurrentWindowStart, TSetCurrentWindowStart }; diff --git a/common/actions/schedule/actionTypes/actionTypes.ts b/common/actions/schedule/actionTypes/actionTypes.ts deleted file mode 100644 index fd0ead35..00000000 --- a/common/actions/schedule/actionTypes/actionTypes.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { ScheduleFieldAction } from './fields'; - -export * from './fields'; - -export type ScheduleAction = ScheduleFieldAction; diff --git a/common/actions/schedule/actionTypes/fields.ts b/common/actions/schedule/actionTypes/fields.ts deleted file mode 100644 index 33177bd9..00000000 --- a/common/actions/schedule/actionTypes/fields.ts +++ /dev/null @@ -1,116 +0,0 @@ -import { TypeKeys } from 'actions/schedule/constants'; -import { Wei } from 'libs/units'; - -interface SetTimeBountyFieldAction { - type: TypeKeys.TIME_BOUNTY_FIELD_SET; - payload: { - raw: string; - value: Wei | null; - }; -} - -interface SetWindowSizeFieldAction { - type: TypeKeys.WINDOW_SIZE_FIELD_SET; - payload: { - raw: string; - value: Wei | null; - }; -} - -interface SetWindowStartFieldAction { - type: TypeKeys.WINDOW_START_FIELD_SET; - payload: { - raw: string; - value: number | null; - }; -} - -interface SetScheduleTimestampFieldAction { - type: TypeKeys.SCHEDULE_TIMESTAMP_FIELD_SET; - payload: { - raw: string; - value: Date; - }; -} - -interface SetScheduleTypeAction { - type: TypeKeys.SCHEDULE_TYPE_SET; - payload: { - raw: string; - value: string | null; - }; -} - -interface SetSchedulingToggleAction { - type: TypeKeys.SCHEDULING_TOGGLE_SET; - payload: { - value: boolean; - }; -} - -interface SetScheduleTimezoneAction { - type: TypeKeys.SCHEDULE_TIMEZONE_SET; - payload: { - raw: string; - value: string; - }; -} - -interface SetScheduleGasPriceFieldAction { - type: TypeKeys.SCHEDULE_GAS_PRICE_FIELD_SET; - payload: { - raw: string; - value: Wei | null; - }; -} - -interface SetScheduleGasLimitFieldAction { - type: TypeKeys.SCHEDULE_GAS_LIMIT_FIELD_SET; - payload: { - raw: string; - value: Wei | null; - }; -} - -interface SetScheduleDepositFieldAction { - type: TypeKeys.SCHEDULE_DEPOSIT_FIELD_SET; - payload: { - raw: string; - value: Wei | null; - }; -} - -interface SetScheduleParamsValidityAction { - type: TypeKeys.SCHEDULE_PARAMS_VALIDITY_SET; - payload: { - value: boolean; - }; -} - -type ScheduleFieldAction = - | SetTimeBountyFieldAction - | SetWindowSizeFieldAction - | SetWindowStartFieldAction - | SetScheduleTimestampFieldAction - | SetScheduleTypeAction - | SetSchedulingToggleAction - | SetScheduleGasPriceFieldAction - | SetScheduleGasLimitFieldAction - | SetScheduleDepositFieldAction - | SetScheduleTimezoneAction - | SetScheduleParamsValidityAction; - -export { - ScheduleFieldAction, - SetTimeBountyFieldAction, - SetWindowSizeFieldAction, - SetWindowStartFieldAction, - SetScheduleTimestampFieldAction, - SetScheduleTypeAction, - SetSchedulingToggleAction, - SetScheduleGasPriceFieldAction, - SetScheduleGasLimitFieldAction, - SetScheduleDepositFieldAction, - SetScheduleTimezoneAction, - SetScheduleParamsValidityAction -}; diff --git a/common/actions/schedule/actionTypes/index.ts b/common/actions/schedule/actionTypes/index.ts deleted file mode 100644 index 3eb256de..00000000 --- a/common/actions/schedule/actionTypes/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './actionTypes'; diff --git a/common/actions/schedule/actionTypes/scheduleTimestamp.ts b/common/actions/schedule/actionTypes/scheduleTimestamp.ts deleted file mode 100644 index 118aeffe..00000000 --- a/common/actions/schedule/actionTypes/scheduleTimestamp.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { TypeKeys } from 'actions/schedule'; - -/* user input */ - -interface SetCurrentScheduleTimestampAction { - type: TypeKeys.CURRENT_SCHEDULE_TIMESTAMP_SET; - payload: string; -} - -type CurrentAction = SetCurrentScheduleTimestampAction; - -interface SetCurrentScheduleTimezoneAction { - type: TypeKeys.CURRENT_SCHEDULE_TIMEZONE_SET; - payload: string; -} - -export { SetCurrentScheduleTimestampAction, CurrentAction, SetCurrentScheduleTimezoneAction }; diff --git a/common/actions/schedule/actionTypes/scheduleType.ts b/common/actions/schedule/actionTypes/scheduleType.ts deleted file mode 100644 index a1cd667f..00000000 --- a/common/actions/schedule/actionTypes/scheduleType.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { TypeKeys } from 'actions/schedule'; - -/* user input */ - -interface SetCurrentScheduleTypeAction { - type: TypeKeys.CURRENT_SCHEDULE_TYPE; - payload: string; -} - -type CurrentAction = SetCurrentScheduleTypeAction; - -export { SetCurrentScheduleTypeAction, CurrentAction }; diff --git a/common/actions/schedule/actionTypes/schedulingToggle.ts b/common/actions/schedule/actionTypes/schedulingToggle.ts deleted file mode 100644 index 64fb3d93..00000000 --- a/common/actions/schedule/actionTypes/schedulingToggle.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { TypeKeys } from 'actions/schedule'; - -/* user input */ - -interface SetCurrentSchedulingToggleAction { - type: TypeKeys.CURRENT_SCHEDULING_TOGGLE; - payload: string; -} - -type CurrentAction = SetCurrentSchedulingToggleAction; - -export { SetCurrentSchedulingToggleAction, CurrentAction }; diff --git a/common/actions/schedule/actionTypes/timeBounty.ts b/common/actions/schedule/actionTypes/timeBounty.ts deleted file mode 100644 index ac35eacd..00000000 --- a/common/actions/schedule/actionTypes/timeBounty.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { TypeKeys } from 'actions/schedule'; - -/* user input */ - -interface SetCurrentTimeBountyAction { - type: TypeKeys.CURRENT_TIME_BOUNTY_SET; - payload: string; -} - -type CurrentAction = SetCurrentTimeBountyAction; - -export { SetCurrentTimeBountyAction, CurrentAction }; diff --git a/common/actions/schedule/actionTypes/windowSize.ts b/common/actions/schedule/actionTypes/windowSize.ts deleted file mode 100644 index fd1465a7..00000000 --- a/common/actions/schedule/actionTypes/windowSize.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { TypeKeys } from 'actions/schedule'; - -/* user input */ - -interface SetCurrentWindowSizeAction { - type: TypeKeys.CURRENT_WINDOW_SIZE_SET; - payload: string; -} - -type CurrentAction = SetCurrentWindowSizeAction; - -export { SetCurrentWindowSizeAction, CurrentAction }; diff --git a/common/actions/schedule/actionTypes/windowStart.ts b/common/actions/schedule/actionTypes/windowStart.ts deleted file mode 100644 index cc528316..00000000 --- a/common/actions/schedule/actionTypes/windowStart.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { TypeKeys } from 'actions/schedule'; - -/* user input */ - -interface SetCurrentWindowStartAction { - type: TypeKeys.CURRENT_WINDOW_START_SET; - payload: string; -} - -type CurrentAction = SetCurrentWindowStartAction; - -export { SetCurrentWindowStartAction, CurrentAction }; diff --git a/common/actions/schedule/constants.ts b/common/actions/schedule/constants.ts deleted file mode 100644 index c3d4b698..00000000 --- a/common/actions/schedule/constants.ts +++ /dev/null @@ -1,21 +0,0 @@ -export enum TypeKeys { - CURRENT_TIME_BOUNTY_SET = 'CURRENT_TIME_BOUNTY_SET', - CURRENT_WINDOW_SIZE_SET = 'CURRENT_WINDOW_SIZE_SET', - CURRENT_WINDOW_START_SET = 'CURRENT_WINDOW_START_SET', - CURRENT_SCHEDULE_TIMESTAMP_SET = 'CURRENT_SCHEDULE_TIMESTAMP_SET', - CURRENT_SCHEDULE_TIMEZONE_SET = 'CURRENT_SCHEDULE_TIMEZONE_SET', - CURRENT_SCHEDULE_TYPE = 'CURRENT_SCHEDULE_TYPE', - CURRENT_SCHEDULING_TOGGLE = 'CURRENT_SCHEDULING_TOGGLE', - - TIME_BOUNTY_FIELD_SET = 'TIME_BOUNTY_FIELD_SET', - WINDOW_SIZE_FIELD_SET = 'WINDOW_SIZE_FIELD_SET', - WINDOW_START_FIELD_SET = 'WINDOW_START_FIELD_SET', - SCHEDULE_GAS_PRICE_FIELD_SET = 'SCHEDULE_GAS_PRICE_SET', - SCHEDULE_GAS_LIMIT_FIELD_SET = 'SCHEDULE_GAS_LIMIT_SET', - SCHEDULE_TIMESTAMP_FIELD_SET = 'SCHEDULE_TIMESTAMP_FIELD_SET', - SCHEDULE_TIMEZONE_SET = 'SCHEDULE_TIMEZONE_SET', - SCHEDULE_TYPE_SET = 'SCHEDULE_TYPE_SET', - SCHEDULING_TOGGLE_SET = 'SCHEDULING_TOGGLE_SET', - SCHEDULE_DEPOSIT_FIELD_SET = 'SCHEDULE_DEPOSIT_FIELD_SET', - SCHEDULE_PARAMS_VALIDITY_SET = 'SCHEDULE_PARAMS_VALIDITY_SET' -} diff --git a/common/actions/schedule/index.ts b/common/actions/schedule/index.ts deleted file mode 100644 index d5122d97..00000000 --- a/common/actions/schedule/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './actionCreators'; -export * from './constants'; -export * from './actionTypes'; diff --git a/common/actions/swap/actionCreators.ts b/common/actions/swap/actionCreators.ts deleted file mode 100644 index 2958a84f..00000000 --- a/common/actions/swap/actionCreators.ts +++ /dev/null @@ -1,269 +0,0 @@ -import * as interfaces from './actionTypes'; -import { TypeKeys } from './constants'; - -export type TChangeStepSwap = typeof changeStepSwap; -export function changeStepSwap(payload: number): interfaces.ChangeStepSwapAction { - return { - type: TypeKeys.SWAP_STEP, - payload - }; -} - -export type TInitSwap = typeof initSwap; -export function initSwap(payload: interfaces.SwapInputs): interfaces.InitSwap { - return { - type: TypeKeys.SWAP_INIT, - payload - }; -} - -export type TLoadBityRatesSucceededSwap = typeof loadBityRatesSucceededSwap; -export function loadBityRatesSucceededSwap( - payload: interfaces.ApiResponse -): interfaces.LoadBityRatesSucceededSwapAction { - return { - type: TypeKeys.SWAP_LOAD_BITY_RATES_SUCCEEDED, - payload - }; -} - -export type TLoadShapeshiftRatesSucceededSwap = typeof loadShapeshiftRatesSucceededSwap; -export function loadShapeshiftRatesSucceededSwap( - payload: interfaces.LoadShapeshiftRatesSucceededSwapAction['payload'] -): interfaces.LoadShapeshiftRatesSucceededSwapAction { - return { - type: TypeKeys.SWAP_LOAD_SHAPESHIFT_RATES_SUCCEEDED, - payload - }; -} - -export type TDestinationAddressSwap = typeof destinationAddressSwap; -export function destinationAddressSwap(payload?: string): interfaces.DestinationAddressSwapAction { - return { - type: TypeKeys.SWAP_DESTINATION_ADDRESS, - payload - }; -} - -export type TRestartSwap = typeof restartSwap; -export function restartSwap(): interfaces.RestartSwapAction { - return { - type: TypeKeys.SWAP_RESTART - }; -} - -export type TLoadBityRatesRequestedSwap = typeof loadBityRatesRequestedSwap; -export function loadBityRatesRequestedSwap(): interfaces.LoadBityRatesRequestedSwapAction { - return { - type: TypeKeys.SWAP_LOAD_BITY_RATES_REQUESTED - }; -} - -export type TLoadShapeshiftRatesRequestedSwap = typeof loadShapeshiftRatesRequestedSwap; -export function loadShapeshiftRatesRequestedSwap(): interfaces.LoadShapeshiftRatesRequestedSwapAction { - return { - type: TypeKeys.SWAP_LOAD_SHAPESHIFT_RATES_REQUESTED - }; -} - -export type TLoadBityRatesFailedSwap = typeof loadBityRatesFailedSwap; -export function loadBityRatesFailedSwap(): interfaces.LoadBityRatesFailedSwapAction { - return { - type: TypeKeys.SWAP_LOAD_BITY_RATES_FAILED - }; -} - -export type TLoadShapeshiftFailedSwap = typeof loadShapeshiftRatesFailedSwap; -export function loadShapeshiftRatesFailedSwap(): interfaces.LoadShapeshiftRatesFailedSwapAction { - return { - type: TypeKeys.SWAP_LOAD_SHAPESHIFT_RATES_FAILED - }; -} - -export type TStopLoadBityRatesSwap = typeof stopLoadBityRatesSwap; -export function stopLoadBityRatesSwap(): interfaces.StopLoadBityRatesSwapAction { - return { - type: TypeKeys.SWAP_STOP_LOAD_BITY_RATES - }; -} - -export type TStopLoadShapeshiftRatesSwap = typeof stopLoadShapeshiftRatesSwap; -export function stopLoadShapeshiftRatesSwap(): interfaces.StopLoadShapeshiftRatesSwapAction { - return { - type: TypeKeys.SWAP_STOP_LOAD_SHAPESHIFT_RATES - }; -} - -export type TOrderTimeSwap = typeof orderTimeSwap; -export function orderTimeSwap(payload: number): interfaces.OrderSwapTimeSwapAction { - return { - type: TypeKeys.SWAP_ORDER_TIME, - payload - }; -} - -export type TBityOrderCreateSucceededSwap = typeof bityOrderCreateSucceededSwap; -export function bityOrderCreateSucceededSwap( - payload: interfaces.BityOrderPostResponse -): interfaces.BityOrderCreateSucceededSwapAction { - return { - type: TypeKeys.SWAP_BITY_ORDER_CREATE_SUCCEEDED, - payload - }; -} - -export type TShapeshiftOrderCreateSucceededSwap = typeof shapeshiftOrderCreateSucceededSwap; -export function shapeshiftOrderCreateSucceededSwap( - payload: interfaces.ShapeshiftOrderResponse -): interfaces.ShapeshiftOrderCreateSucceededSwapAction { - return { - type: TypeKeys.SWAP_SHAPESHIFT_ORDER_CREATE_SUCCEEDED, - payload - }; -} - -export type TBityOrderCreateRequestedSwap = typeof bityOrderCreateRequestedSwap; -export function bityOrderCreateRequestedSwap( - amount: number, - destinationAddress: string, - pair: string, - mode: number = 0 -): interfaces.BityOrderCreateRequestedSwapAction { - return { - type: TypeKeys.SWAP_BITY_ORDER_CREATE_REQUESTED, - payload: { - amount, - destinationAddress, - pair, - mode - } - }; -} - -export type TShapeshiftOrderCreateRequestedSwap = typeof shapeshiftOrderCreateRequestedSwap; -export function shapeshiftOrderCreateRequestedSwap( - withdrawal: string, - originKind: string, - destinationKind: string, - destinationAmount: number -): interfaces.ShapeshiftOrderCreateRequestedSwapAction { - return { - type: TypeKeys.SWAP_SHAPESHIFT_ORDER_CREATE_REQUESTED, - payload: { - withdrawal, - originKind, - destinationKind, - destinationAmount - } - }; -} - -export function bityOrderCreateFailedSwap(): interfaces.BityOrderCreateFailedSwapAction { - return { - type: TypeKeys.SWAP_BITY_ORDER_CREATE_FAILED - }; -} - -export function shapeshiftOrderCreateFailedSwap(): interfaces.ShapeshiftOrderCreateFailedSwapAction { - return { - type: TypeKeys.SWAP_SHAPESHIFT_ORDER_CREATE_FAILED - }; -} - -export type TBityOrderStatusSucceededSwap = typeof bityOrderStatusSucceededSwap; -export function bityOrderStatusSucceededSwap( - payload: interfaces.BityOrderResponse -): interfaces.BityOrderStatusSucceededSwapAction { - return { - type: TypeKeys.SWAP_BITY_ORDER_STATUS_SUCCEEDED, - payload - }; -} - -export type TShapeshiftOrderStatusSucceededSwap = typeof shapeshiftOrderStatusSucceededSwap; -export function shapeshiftOrderStatusSucceededSwap( - payload: interfaces.ShapeshiftStatusResponse -): interfaces.ShapeshiftOrderStatusSucceededSwapAction { - return { - type: TypeKeys.SWAP_SHAPESHIFT_ORDER_STATUS_SUCCEEDED, - payload - }; -} - -export type TBityOrderStatusRequestedSwap = typeof bityOrderStatusRequested; -export function bityOrderStatusRequested(): interfaces.BityOrderStatusRequestedSwapAction { - return { - type: TypeKeys.SWAP_BITY_ORDER_STATUS_REQUESTED - }; -} - -export type TShapeshiftOrderStatusRequestedSwap = typeof shapeshiftOrderStatusRequested; -export function shapeshiftOrderStatusRequested(): interfaces.ShapeshiftOrderStatusRequestedSwapAction { - return { - type: TypeKeys.SWAP_SHAPESHIFT_ORDER_STATUS_REQUESTED - }; -} - -export type TStartOrderTimerSwap = typeof startOrderTimerSwap; -export function startOrderTimerSwap(): interfaces.StartOrderTimerSwapAction { - return { - type: TypeKeys.SWAP_ORDER_START_TIMER - }; -} - -export type TStopOrderTimerSwap = typeof stopOrderTimerSwap; -export function stopOrderTimerSwap(): interfaces.StopOrderTimerSwapAction { - return { - type: TypeKeys.SWAP_ORDER_STOP_TIMER - }; -} - -export type TStartPollBityOrderStatus = typeof startPollBityOrderStatus; -export function startPollBityOrderStatus(): interfaces.StartPollBityOrderStatusAction { - return { - type: TypeKeys.SWAP_START_POLL_BITY_ORDER_STATUS - }; -} - -export type TStartPollShapeshiftOrderStatus = typeof startPollShapeshiftOrderStatus; -export function startPollShapeshiftOrderStatus(): interfaces.StartPollShapeshiftOrderStatusAction { - return { - type: TypeKeys.SWAP_START_POLL_SHAPESHIFT_ORDER_STATUS - }; -} - -export type TStopPollBityOrderStatus = typeof stopPollBityOrderStatus; -export function stopPollBityOrderStatus(): interfaces.StopPollBityOrderStatusAction { - return { - type: TypeKeys.SWAP_STOP_POLL_BITY_ORDER_STATUS - }; -} - -export type TStopPollShapeshiftOrderStatus = typeof stopPollShapeshiftOrderStatus; -export function stopPollShapeshiftOrderStatus(): interfaces.StopPollShapeshiftOrderStatusAction { - return { - type: TypeKeys.SWAP_STOP_POLL_SHAPESHIFT_ORDER_STATUS - }; -} - -export type TConfigureLiteSend = typeof configureLiteSend; -export function configureLiteSend(): interfaces.ConfigureLiteSendAction { - return { type: TypeKeys.SWAP_CONFIGURE_LITE_SEND }; -} - -export type TShowLiteSend = typeof showLiteSend; -export function showLiteSend( - payload: interfaces.ShowLiteSendAction['payload'] -): interfaces.ShowLiteSendAction { - return { type: TypeKeys.SWAP_SHOW_LITE_SEND, payload }; -} - -export type TChangeSwapProvider = typeof changeSwapProvider; -export function changeSwapProvider( - payload: interfaces.ProviderName -): interfaces.ChangeProviderSwapAcion { - return { - type: TypeKeys.SWAP_CHANGE_PROVIDER, - payload - }; -} diff --git a/common/actions/swap/actionTypes.ts b/common/actions/swap/actionTypes.ts deleted file mode 100644 index b5b636e1..00000000 --- a/common/actions/swap/actionTypes.ts +++ /dev/null @@ -1,272 +0,0 @@ -import { TypeKeys } from './constants'; - -export interface Pairs { - ETHBTC: number; - ETHREP: number; - BTCETH: number; - BTCREP: number; -} - -export interface SwapInput { - label: string; - amount: number | string; -} - -export interface SwapInputs { - origin: SwapInput; - destination: SwapInput; -} - -export interface InitSwap { - type: TypeKeys.SWAP_INIT; - payload: SwapInputs; -} - -export interface Option { - id: string; - status?: string; - image?: string; -} - -export interface ApiResponseObj { - id: string; - options: Option[]; - rate: number; -} - -export interface ApiResponse { - [name: string]: ApiResponseObj; -} - -export interface LoadBityRatesSucceededSwapAction { - type: TypeKeys.SWAP_LOAD_BITY_RATES_SUCCEEDED; - payload: ApiResponse; -} - -export interface LoadShapeshiftRatesSucceededSwapAction { - type: TypeKeys.SWAP_LOAD_SHAPESHIFT_RATES_SUCCEEDED; - payload: ApiResponse; -} - -export interface DestinationAddressSwapAction { - type: TypeKeys.SWAP_DESTINATION_ADDRESS; - payload?: string; -} - -export interface RestartSwapAction { - type: TypeKeys.SWAP_RESTART; -} - -export interface LoadBityRatesRequestedSwapAction { - type: TypeKeys.SWAP_LOAD_BITY_RATES_REQUESTED; -} - -export interface LoadShapeshiftRatesRequestedSwapAction { - type: TypeKeys.SWAP_LOAD_SHAPESHIFT_RATES_REQUESTED; -} - -export interface LoadBityRatesFailedSwapAction { - type: TypeKeys.SWAP_LOAD_BITY_RATES_FAILED; -} - -export interface LoadShapeshiftRatesFailedSwapAction { - type: TypeKeys.SWAP_LOAD_SHAPESHIFT_RATES_FAILED; -} - -export interface ChangeStepSwapAction { - type: TypeKeys.SWAP_STEP; - payload: number; -} - -export interface StopLoadBityRatesSwapAction { - type: TypeKeys.SWAP_STOP_LOAD_BITY_RATES; -} - -export interface StopLoadShapeshiftRatesSwapAction { - type: TypeKeys.SWAP_STOP_LOAD_SHAPESHIFT_RATES; -} - -export interface OrderSwapTimeSwapAction { - type: TypeKeys.SWAP_ORDER_TIME; - payload: number; -} - -export interface BityOrderCreateRequestedSwapAction { - type: TypeKeys.SWAP_BITY_ORDER_CREATE_REQUESTED; - payload: { - amount: number; - destinationAddress: string; - pair: string; - mode: number; - }; -} - -export interface ShapeshiftOrderCreateRequestedSwapAction { - type: TypeKeys.SWAP_SHAPESHIFT_ORDER_CREATE_REQUESTED; - payload: { - withdrawal: string; - originKind: string; - destinationKind: string; - destinationAmount: number; - }; -} - -export interface BityOrderInput { - amount: string; - currency: string; - reference: string; - status: string; -} - -export interface BityOrderOutput { - amount: string; - currency: string; - reference: string; - status: string; -} - -export interface BityOrderResponse { - input: BityOrderInput; - output: BityOrderOutput; - status: string; -} - -export interface ShapeshiftOrderResponse { - apiPubKey?: string; - deposit: string; - depositAmount: string; - expiration: number; - expirationFormatted?: string; - inputCurrency?: string; - maxLimit: number; - minerFee: string; - orderId: string; - outputCurrency?: string; - pair: string; // e.g. eth_bat - provider?: ProviderName; // shapeshift - quotedRate: string; - withdrawal: string; - withdrawalAmount: string; -} - -export interface ShapeshiftStatusResponse { - status: string; - address?: string; - withdraw?: string; - transaction: string; -} - -export type BityOrderPostResponse = BityOrderResponse & { - payment_address: string; - status: string; - input: BityOrderInput; - output: BityOrderOutput; - timestamp_created: string; - validFor: number; - id: string; -}; - -export type ProviderName = 'shapeshift' | 'bity'; - -export interface BityOrderCreateSucceededSwapAction { - type: TypeKeys.SWAP_BITY_ORDER_CREATE_SUCCEEDED; - payload: BityOrderPostResponse; -} - -export interface ShapeshiftOrderCreateSucceededSwapAction { - type: TypeKeys.SWAP_SHAPESHIFT_ORDER_CREATE_SUCCEEDED; - payload: ShapeshiftOrderResponse; -} - -export interface BityOrderCreateFailedSwapAction { - type: TypeKeys.SWAP_BITY_ORDER_CREATE_FAILED; -} - -export interface ShapeshiftOrderCreateFailedSwapAction { - type: TypeKeys.SWAP_SHAPESHIFT_ORDER_CREATE_FAILED; -} - -export interface BityOrderStatusRequestedSwapAction { - type: TypeKeys.SWAP_BITY_ORDER_STATUS_REQUESTED; -} - -export interface ShapeshiftOrderStatusRequestedSwapAction { - type: TypeKeys.SWAP_SHAPESHIFT_ORDER_STATUS_REQUESTED; -} - -export interface BityOrderStatusSucceededSwapAction { - type: TypeKeys.SWAP_BITY_ORDER_STATUS_SUCCEEDED; - payload: BityOrderResponse; -} - -export interface ShapeshiftOrderStatusSucceededSwapAction { - type: TypeKeys.SWAP_SHAPESHIFT_ORDER_STATUS_SUCCEEDED; - payload: ShapeshiftStatusResponse; -} - -export interface StartOrderTimerSwapAction { - type: TypeKeys.SWAP_ORDER_START_TIMER; -} - -export interface StopOrderTimerSwapAction { - type: TypeKeys.SWAP_ORDER_STOP_TIMER; -} - -export interface StartPollBityOrderStatusAction { - type: TypeKeys.SWAP_START_POLL_BITY_ORDER_STATUS; -} - -export interface StartPollShapeshiftOrderStatusAction { - type: TypeKeys.SWAP_START_POLL_SHAPESHIFT_ORDER_STATUS; -} - -export interface StopPollBityOrderStatusAction { - type: TypeKeys.SWAP_STOP_POLL_BITY_ORDER_STATUS; -} - -export interface StopPollShapeshiftOrderStatusAction { - type: TypeKeys.SWAP_STOP_POLL_SHAPESHIFT_ORDER_STATUS; -} - -export interface ChangeProviderSwapAcion { - type: TypeKeys.SWAP_CHANGE_PROVIDER; - payload: ProviderName; -} - -export interface ConfigureLiteSendAction { - type: TypeKeys.SWAP_CONFIGURE_LITE_SEND; -} - -export interface ShowLiteSendAction { - type: TypeKeys.SWAP_SHOW_LITE_SEND; - payload: boolean; -} - -/*** Action Type Union ***/ -export type SwapAction = - | ChangeStepSwapAction - | InitSwap - | DestinationAddressSwapAction - | RestartSwapAction - | LoadBityRatesRequestedSwapAction - | LoadBityRatesSucceededSwapAction - | LoadBityRatesFailedSwapAction - | LoadShapeshiftRatesRequestedSwapAction - | LoadShapeshiftRatesSucceededSwapAction - | LoadShapeshiftRatesFailedSwapAction - | StopLoadBityRatesSwapAction - | StopLoadShapeshiftRatesSwapAction - | BityOrderCreateRequestedSwapAction - | ShapeshiftOrderCreateRequestedSwapAction - | BityOrderCreateSucceededSwapAction - | ShapeshiftOrderCreateSucceededSwapAction - | BityOrderStatusSucceededSwapAction - | ShapeshiftOrderStatusSucceededSwapAction - | StartPollBityOrderStatusAction - | StartPollShapeshiftOrderStatusAction - | BityOrderCreateFailedSwapAction - | ShapeshiftOrderCreateFailedSwapAction - | OrderSwapTimeSwapAction - | ChangeProviderSwapAcion - | ConfigureLiteSendAction - | ShowLiteSendAction; diff --git a/common/actions/swap/constants.ts b/common/actions/swap/constants.ts deleted file mode 100644 index 1fdfc4f3..00000000 --- a/common/actions/swap/constants.ts +++ /dev/null @@ -1,34 +0,0 @@ -export enum TypeKeys { - SWAP_STEP = 'SWAP_STEP', - SWAP_INIT = 'SWAP_INIT', - SWAP_LOAD_BITY_RATES_SUCCEEDED = 'SWAP_LOAD_BITY_RATES_SUCCEEDED', - SWAP_LOAD_SHAPESHIFT_RATES_SUCCEEDED = 'SWAP_LOAD_SHAPESHIFT_RATES_SUCCEEDED', - SWAP_DESTINATION_ADDRESS = 'SWAP_DESTINATION_ADDRESS', - SWAP_RESTART = 'SWAP_RESTART', - SWAP_LOAD_BITY_RATES_REQUESTED = 'SWAP_LOAD_BITY_RATES_REQUESTED', - SWAP_LOAD_SHAPESHIFT_RATES_REQUESTED = 'SWAP_LOAD_SHAPESHIFT_RATES_REQUESTED', - SWAP_LOAD_BITY_RATES_FAILED = 'SWAP_LOAD_BITY_RATES_FAILED', - SWAP_LOAD_SHAPESHIFT_RATES_FAILED = 'SWAP_LOAD_SHAPESHIFT_RATES_FAILED', - SWAP_STOP_LOAD_BITY_RATES = 'SWAP_STOP_LOAD_BITY_RATES', - SWAP_STOP_LOAD_SHAPESHIFT_RATES = 'SWAP_STOP_LOAD_SHAPESHIFT_RATES', - SWAP_ORDER_TIME = 'SWAP_ORDER_TIME', - SWAP_BITY_ORDER_CREATE_SUCCEEDED = 'SWAP_BITY_ORDER_CREATE_SUCCEEDED', - SWAP_SHAPESHIFT_ORDER_CREATE_SUCCEEDED = 'SWAP_SHAPESHIFT_ORDER_CREATE_SUCCEEDED', - SWAP_BITY_ORDER_STATUS_SUCCEEDED = 'SWAP_BITY_ORDER_STATUS_SUCCEEDED', - SWAP_SHAPESHIFT_ORDER_STATUS_SUCCEEDED = 'SWAP_SHAPESHIFT_ORDER_STATUS_SUCCEEDED', - SWAP_BITY_ORDER_STATUS_REQUESTED = 'SWAP_BITY_ORDER_STATUS_REQUESTED', - SWAP_SHAPESHIFT_ORDER_STATUS_REQUESTED = 'SWAP_SHAPESHIFT_ORDER_STATUS_REQUESTED', - SWAP_ORDER_START_TIMER = 'SWAP_ORDER_START_TIMER', - SWAP_ORDER_STOP_TIMER = 'SWAP_ORDER_STOP_TIMER', - SWAP_START_POLL_BITY_ORDER_STATUS = 'SWAP_START_POLL_BITY_ORDER_STATUS', - SWAP_START_POLL_SHAPESHIFT_ORDER_STATUS = 'SWAP_START_POLL_SHAPESHIFT_ORDER_STATUS', - SWAP_STOP_POLL_BITY_ORDER_STATUS = 'SWAP_STOP_POLL_BITY_ORDER_STATUS', - SWAP_STOP_POLL_SHAPESHIFT_ORDER_STATUS = 'SWAP_STOP_POLL_SHAPESHIFT_ORDER_STATUS', - SWAP_BITY_ORDER_CREATE_REQUESTED = 'SWAP_ORDER_CREATE_REQUESTED', - SWAP_SHAPESHIFT_ORDER_CREATE_REQUESTED = 'SWAP_SHAPESHIFT_ORDER_CREATE_REQUESTED', - SWAP_BITY_ORDER_CREATE_FAILED = 'SWAP_ORDER_CREATE_FAILED', - SWAP_SHAPESHIFT_ORDER_CREATE_FAILED = 'SWAP_SHAPESHIFT_ORDER_CREATE_FAILED', - SWAP_CHANGE_PROVIDER = 'SWAP_CHANGE_PROVIDER', - SWAP_CONFIGURE_LITE_SEND = 'SWAP_CONFIGURE_LITE_SEND', - SWAP_SHOW_LITE_SEND = 'SWAP_SHOW_LITE_SEND' -} diff --git a/common/actions/swap/index.ts b/common/actions/swap/index.ts deleted file mode 100644 index 2608a18e..00000000 --- a/common/actions/swap/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './actionTypes'; -export * from './actionCreators'; diff --git a/common/actions/transaction/actionCreators/broadcast.ts b/common/actions/transaction/actionCreators/broadcast.ts deleted file mode 100644 index 1b50d676..00000000 --- a/common/actions/transaction/actionCreators/broadcast.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { - BroadcastLocalTransactionRequestedAction, - BroadcastWeb3TransactionRequestedAction, - BroadcastTransactionFailedAction, - BroadcastTransactionSucceededAction, - BroadcastTransactionQueuedAction -} from '../actionTypes'; -import { TypeKeys } from '../constants'; - -type TBroadcastLocalTransactionRequested = typeof broadcastLocalTransactionRequested; -const broadcastLocalTransactionRequested = (): BroadcastLocalTransactionRequestedAction => ({ - type: TypeKeys.BROADCAST_LOCAL_TRANSACTION_REQUESTED -}); - -type TBroadcastWeb3TransactionRequested = typeof broadcastWeb3TransactionRequested; -const broadcastWeb3TransactionRequested = (): BroadcastWeb3TransactionRequestedAction => ({ - type: TypeKeys.BROADCAST_WEB3_TRANSACTION_REQUESTED -}); - -type TBroadcastTransactionSucceeded = typeof broadcastTransactionSucceeded; -const broadcastTransactionSucceeded = ( - payload: BroadcastTransactionSucceededAction['payload'] -): BroadcastTransactionSucceededAction => ({ - type: TypeKeys.BROADCAST_TRANSACTION_SUCCEEDED, - payload -}); - -type TBroadcastTransactionFailed = typeof broadcastTransactionFailed; -const broadcastTransactionFailed = ( - payload: BroadcastTransactionFailedAction['payload'] -): BroadcastTransactionFailedAction => ({ - type: TypeKeys.BROADCAST_TRASACTION_FAILED, - payload -}); - -type TBroadcastTransactionQueued = typeof broadcastTransactionQueued; -const broadcastTransactionQueued = ( - payload: BroadcastTransactionQueuedAction['payload'] -): BroadcastTransactionQueuedAction => ({ - type: TypeKeys.BROADCAST_TRANSACTION_QUEUED, - payload -}); - -export { - broadcastLocalTransactionRequested, - broadcastWeb3TransactionRequested, - broadcastTransactionSucceeded, - broadcastTransactionFailed, - broadcastTransactionQueued, - TBroadcastLocalTransactionRequested, - TBroadcastWeb3TransactionRequested, - TBroadcastTransactionSucceeded, - TBroadcastTransactionFailed, - TBroadcastTransactionQueued -}; diff --git a/common/actions/transaction/actionCreators/current.ts b/common/actions/transaction/actionCreators/current.ts deleted file mode 100644 index c9c1f29b..00000000 --- a/common/actions/transaction/actionCreators/current.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { SetCurrentToAction, SetCurrentValueAction } from '../actionTypes/current'; -import { TypeKeys } from '../'; - -type TSetCurrentValue = typeof setCurrentValue; -const setCurrentValue = (payload: SetCurrentValueAction['payload']): SetCurrentValueAction => ({ - type: TypeKeys.CURRENT_VALUE_SET, - payload -}); - -type TSetCurrentTo = typeof setCurrentTo; -const setCurrentTo = (payload: SetCurrentToAction['payload']): SetCurrentToAction => ({ - type: TypeKeys.CURRENT_TO_SET, - payload -}); - -export { setCurrentValue, setCurrentTo, TSetCurrentTo, TSetCurrentValue }; diff --git a/common/actions/transaction/actionCreators/fields.ts b/common/actions/transaction/actionCreators/fields.ts deleted file mode 100644 index 2df5bb1a..00000000 --- a/common/actions/transaction/actionCreators/fields.ts +++ /dev/null @@ -1,124 +0,0 @@ -import { - SetGasLimitFieldAction, - SetDataFieldAction, - SetToFieldAction, - SetNonceFieldAction, - SetValueFieldAction, - InputGasLimitAction, - InputGasPriceAction, - InputGasPriceIntentAction, - InputDataAction, - InputNonceAction, - ResetTransactionRequestedAction, - ResetTransactionSuccessfulAction, - SetGasPriceFieldAction -} from '../actionTypes'; -import { TypeKeys } from 'actions/transaction/constants'; - -type TInputGasLimit = typeof inputGasLimit; -const inputGasLimit = (payload: InputGasLimitAction['payload']) => ({ - type: TypeKeys.GAS_LIMIT_INPUT, - payload -}); - -type TInputGasPrice = typeof inputGasPrice; -const inputGasPrice = (payload: InputGasPriceAction['payload']) => ({ - type: TypeKeys.GAS_PRICE_INPUT, - payload -}); - -type TInputGasPriceIntent = typeof inputGasPrice; -const inputGasPriceIntent = (payload: InputGasPriceIntentAction['payload']) => ({ - type: TypeKeys.GAS_PRICE_INPUT_INTENT, - payload -}); - -type TInputNonce = typeof inputNonce; -const inputNonce = (payload: InputNonceAction['payload']) => ({ - type: TypeKeys.NONCE_INPUT, - payload -}); - -type TInputData = typeof inputData; -const inputData = (payload: InputDataAction['payload']) => ({ - type: TypeKeys.DATA_FIELD_INPUT, - payload -}); - -type TSetGasLimitField = typeof setGasLimitField; -const setGasLimitField = (payload: SetGasLimitFieldAction['payload']): SetGasLimitFieldAction => ({ - type: TypeKeys.GAS_LIMIT_FIELD_SET, - payload -}); - -type TSetDataField = typeof setDataField; -const setDataField = (payload: SetDataFieldAction['payload']): SetDataFieldAction => ({ - type: TypeKeys.DATA_FIELD_SET, - payload -}); - -type TSetToField = typeof setToField; -const setToField = (payload: SetToFieldAction['payload']): SetToFieldAction => ({ - type: TypeKeys.TO_FIELD_SET, - payload -}); - -type TSetNonceField = typeof setNonceField; -const setNonceField = (payload: SetNonceFieldAction['payload']): SetNonceFieldAction => ({ - type: TypeKeys.NONCE_FIELD_SET, - payload -}); - -type TSetValueField = typeof setValueField; -const setValueField = (payload: SetValueFieldAction['payload']): SetValueFieldAction => ({ - type: TypeKeys.VALUE_FIELD_SET, - payload -}); - -type TSetGasPriceField = typeof setGasPriceField; -const setGasPriceField = (payload: SetGasPriceFieldAction['payload']): SetGasPriceFieldAction => ({ - type: TypeKeys.GAS_PRICE_FIELD_SET, - payload -}); - -type TResetTransactionRequested = typeof resetTransactionRequested; -const resetTransactionRequested = (): ResetTransactionRequestedAction => ({ - type: TypeKeys.RESET_REQUESTED -}); - -type TResetTransactionSuccessful = typeof resetTransactionSuccessful; -const resetTransactionSuccessful = ( - payload: ResetTransactionSuccessfulAction['payload'] -): ResetTransactionSuccessfulAction => ({ - type: TypeKeys.RESET_SUCCESSFUL, - payload -}); - -export { - TInputGasLimit, - TInputGasPrice, - TInputGasPriceIntent, - TInputNonce, - TInputData, - TSetGasLimitField, - TSetDataField, - TSetToField, - TSetNonceField, - TSetValueField, - TSetGasPriceField, - TResetTransactionRequested, - TResetTransactionSuccessful, - inputGasLimit, - inputGasPrice, - inputGasPriceIntent, - inputNonce, - inputData, - setGasLimitField, - setDataField, - setToField, - setNonceField, - setValueField, - setGasPriceField, - resetTransactionRequested, - resetTransactionSuccessful -}; diff --git a/common/actions/transaction/actionCreators/index.ts b/common/actions/transaction/actionCreators/index.ts deleted file mode 100644 index 32cc4be7..00000000 --- a/common/actions/transaction/actionCreators/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './fields'; -export * from './meta'; -export * from './network'; -export * from './sign'; -export * from './broadcast'; -export * from './current'; -export * from './sendEverything'; diff --git a/common/actions/transaction/actionCreators/meta.ts b/common/actions/transaction/actionCreators/meta.ts deleted file mode 100644 index 912d586f..00000000 --- a/common/actions/transaction/actionCreators/meta.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { - TypeKeys, - SetUnitMetaAction, - SetTokenValueMetaAction, - SetTokenToMetaAction, - SetAsContractInteractionAction, - SetAsViewAndSendAction -} from 'actions/transaction'; - -export type TSetTokenTo = typeof setTokenTo; -export const setTokenTo = (payload: SetTokenToMetaAction['payload']): SetTokenToMetaAction => ({ - type: TypeKeys.TOKEN_TO_META_SET, - payload -}); - -export type TSetTokenValue = typeof setTokenValue; -export const setTokenValue = ( - payload: SetTokenValueMetaAction['payload'] -): SetTokenValueMetaAction => ({ - type: TypeKeys.TOKEN_VALUE_META_SET, - payload -}); - -export type TSetUnitMeta = typeof setUnitMeta; -export const setUnitMeta = (payload: SetUnitMetaAction['payload']): SetUnitMetaAction => ({ - type: TypeKeys.UNIT_META_SET, - payload -}); - -export type TSetAsContractInteraction = typeof setAsContractInteraction; -export const setAsContractInteraction = (): SetAsContractInteractionAction => ({ - type: TypeKeys.IS_CONTRACT_INTERACTION -}); - -export type TSetAsViewAndSend = typeof setAsViewAndSend; -export const setAsViewAndSend = (): SetAsViewAndSendAction => ({ type: TypeKeys.IS_VIEW_AND_SEND }); diff --git a/common/actions/transaction/actionCreators/network.ts b/common/actions/transaction/actionCreators/network.ts deleted file mode 100644 index 94aa6f25..00000000 --- a/common/actions/transaction/actionCreators/network.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { - TypeKeys, - EstimateGasFailedAction, - EstimateGasRequestedAction, - EstimateGasTimeoutAction, - EstimateGasSucceededAction, - GetFromRequestedAction, - GetFromSucceededAction, - GetFromFailedAction, - GetNonceRequestedAction, - GetNonceSucceededAction, - GetNonceFailedAction -} from 'actions/transaction'; - -type TEstimateGasRequested = typeof estimateGasRequested; -const estimateGasRequested = ( - payload: EstimateGasRequestedAction['payload'] -): EstimateGasRequestedAction => ({ - type: TypeKeys.ESTIMATE_GAS_REQUESTED, - payload -}); - -type TEstimateGasSucceeded = typeof estimateGasSucceeded; -const estimateGasSucceeded = (): EstimateGasSucceededAction => ({ - type: TypeKeys.ESTIMATE_GAS_SUCCEEDED -}); - -type TEstimateGasFailed = typeof estimateGasFailed; -const estimateGasFailed = (): EstimateGasFailedAction => ({ - type: TypeKeys.ESTIMATE_GAS_FAILED -}); - -type TEstimateGasTimedout = typeof estimateGasTimedout; -const estimateGasTimedout = (): EstimateGasTimeoutAction => ({ - type: TypeKeys.ESTIMATE_GAS_TIMEDOUT -}); - -type TGetFromRequested = typeof getFromRequested; -const getFromRequested = (): GetFromRequestedAction => ({ - type: TypeKeys.GET_FROM_REQUESTED -}); - -type TGetFromSucceeded = typeof getFromSucceeded; -const getFromSucceeded = (payload: GetFromSucceededAction['payload']): GetFromSucceededAction => ({ - type: TypeKeys.GET_FROM_SUCCEEDED, - payload -}); - -type TGetFromFailed = typeof getFromFailed; -const getFromFailed = (): GetFromFailedAction => ({ - type: TypeKeys.GET_FROM_FAILED -}); - -type TGetNonceRequested = typeof getNonceRequested; -const getNonceRequested = (): GetNonceRequestedAction => ({ - type: TypeKeys.GET_NONCE_REQUESTED -}); - -type TGetNonceSucceeded = typeof getNonceSucceeded; -const getNonceSucceeded = ( - payload: GetNonceSucceededAction['payload'] -): GetNonceSucceededAction => ({ type: TypeKeys.GET_NONCE_SUCCEEDED, payload }); - -type TGetNonceFailed = typeof getNonceFailed; -const getNonceFailed = (): GetNonceFailedAction => ({ - type: TypeKeys.GET_NONCE_FAILED -}); - -export { - estimateGasRequested, - estimateGasFailed, - estimateGasTimedout, - estimateGasSucceeded, - getFromRequested, - getFromSucceeded, - getFromFailed, - getNonceRequested, - getNonceFailed, - getNonceSucceeded, - TEstimateGasRequested, - TEstimateGasFailed, - TEstimateGasSucceeded, - TEstimateGasTimedout, - TGetFromRequested, - TGetFromSucceeded, - TGetNonceRequested, - TGetNonceSucceeded, - TGetNonceFailed, - TGetFromFailed -}; diff --git a/common/actions/transaction/actionCreators/sendEverything.ts b/common/actions/transaction/actionCreators/sendEverything.ts deleted file mode 100644 index c9a86471..00000000 --- a/common/actions/transaction/actionCreators/sendEverything.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { - SendEverythingFailedAction, - SendEverythingRequestedAction, - SendEverythingSucceededAction -} from '../actionTypes/sendEverything'; -import { TypeKeys } from 'actions/transaction'; - -type TSendEverythingRequested = typeof sendEverythingRequested; -const sendEverythingRequested = (): SendEverythingRequestedAction => ({ - type: TypeKeys.SEND_EVERYTHING_REQUESTED -}); - -type TSendEverythingFailed = typeof sendEverythingFailed; -const sendEverythingFailed = (): SendEverythingFailedAction => ({ - type: TypeKeys.SEND_EVERYTHING_FAILED -}); - -type TSendEverythingSucceeded = typeof sendEverythingSucceeded; -const sendEverythingSucceeded = (): SendEverythingSucceededAction => ({ - type: TypeKeys.SEND_EVERYTHING_SUCCEEDED -}); - -export { - TSendEverythingRequested, - TSendEverythingFailed, - TSendEverythingSucceeded, - sendEverythingRequested, - sendEverythingFailed, - sendEverythingSucceeded -}; diff --git a/common/actions/transaction/actionCreators/sign.ts b/common/actions/transaction/actionCreators/sign.ts deleted file mode 100644 index 2ede9c25..00000000 --- a/common/actions/transaction/actionCreators/sign.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { - SignTransactionFailedAction, - SignLocalTransactionSucceededAction, - SignWeb3TransactionSucceededAction, - SignTransactionRequestedAction -} from '../actionTypes'; -import { TypeKeys } from '../constants'; - -type TSignTransactionFailed = typeof signTransactionFailed; -const signTransactionFailed = (): SignTransactionFailedAction => ({ - type: TypeKeys.SIGN_TRANSACTION_FAILED -}); - -type TSignTransactionRequested = typeof signTransactionRequested; -const signTransactionRequested = (payload: SignTransactionRequestedAction['payload']) => ({ - type: TypeKeys.SIGN_TRANSACTION_REQUESTED, - payload -}); - -type TSignLocalTransactionSucceeded = typeof signLocalTransactionSucceeded; -const signLocalTransactionSucceeded = ( - payload: SignLocalTransactionSucceededAction['payload'] -): SignLocalTransactionSucceededAction => ({ - type: TypeKeys.SIGN_LOCAL_TRANSACTION_SUCCEEDED, - payload -}); - -type TSignWeb3TransactionSucceeded = typeof signWeb3TransactionSucceeded; -const signWeb3TransactionSucceeded = ( - payload: SignWeb3TransactionSucceededAction['payload'] -): SignWeb3TransactionSucceededAction => ({ - type: TypeKeys.SIGN_WEB3_TRANSACTION_SUCCEEDED, - payload -}); - -export { - signTransactionRequested, - signTransactionFailed, - signLocalTransactionSucceeded, - signWeb3TransactionSucceeded, - TSignLocalTransactionSucceeded, - TSignWeb3TransactionSucceeded, - TSignTransactionFailed, - TSignTransactionRequested -}; diff --git a/common/actions/transaction/actionCreators/swap.ts b/common/actions/transaction/actionCreators/swap.ts deleted file mode 100644 index be92e192..00000000 --- a/common/actions/transaction/actionCreators/swap.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { - SwapEtherToTokenAction, - SwapTokenToEtherAction, - SwapTokenToTokenAction -} from '../actionTypes'; -import { TypeKeys } from '../constants'; - -type TSwapTokenToEther = typeof swapTokenToEther; -const swapTokenToEther = (payload: SwapTokenToEtherAction['payload']): SwapTokenToEtherAction => ({ - type: TypeKeys.TOKEN_TO_ETHER_SWAP, - payload -}); - -type TSwapEtherToToken = typeof swapEtherToToken; -const swapEtherToToken = (payload: SwapEtherToTokenAction['payload']): SwapEtherToTokenAction => ({ - payload, - type: TypeKeys.ETHER_TO_TOKEN_SWAP -}); - -type TSwapTokenToToken = typeof swapTokenToToken; -const swapTokenToToken = (payload: SwapTokenToTokenAction['payload']): SwapTokenToTokenAction => ({ - payload, - type: TypeKeys.TOKEN_TO_TOKEN_SWAP -}); - -export { - swapEtherToToken, - swapTokenToEther, - swapTokenToToken, - TSwapTokenToEther, - TSwapEtherToToken, - TSwapTokenToToken -}; diff --git a/common/actions/transaction/actionTypes/actionTypes.ts b/common/actions/transaction/actionTypes/actionTypes.ts deleted file mode 100644 index fb7863ee..00000000 --- a/common/actions/transaction/actionTypes/actionTypes.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { TypeKeys } from '../constants'; -import { BroadcastAction } from './broadcast'; -import { FieldAction, InputFieldAction } from './fields'; -import { MetaAction } from './meta'; -import { NetworkAction } from './network'; -import { SignAction } from './sign'; -import { SwapAction } from './swap'; -import { CurrentAction } from './current'; -import { SendEverythingAction } from './sendEverything'; - -export * from './broadcast'; -export * from './fields'; -export * from './meta'; -export * from './network'; -export * from './sign'; -export * from './swap'; -export * from './current'; -export * from './sendEverything'; - -export interface ResetTransactionRequestedAction { - type: TypeKeys.RESET_REQUESTED; -} - -export interface ResetTransactionSuccessfulAction { - type: TypeKeys.RESET_SUCCESSFUL; - payload: { isContractInteraction: boolean }; -} - -export type TransactionAction = - | InputFieldAction - | BroadcastAction - | FieldAction - | MetaAction - | NetworkAction - | SignAction - | SwapAction - | ResetTransactionRequestedAction - | ResetTransactionSuccessfulAction - | CurrentAction - | SendEverythingAction; diff --git a/common/actions/transaction/actionTypes/broadcast.ts b/common/actions/transaction/actionTypes/broadcast.ts deleted file mode 100644 index 7cefd93d..00000000 --- a/common/actions/transaction/actionTypes/broadcast.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { TypeKeys } from 'actions/transaction'; -/* Broadcasting actions */ -interface BroadcastLocalTransactionRequestedAction { - type: TypeKeys.BROADCAST_LOCAL_TRANSACTION_REQUESTED; -} -interface BroadcastWeb3TransactionRequestedAction { - type: TypeKeys.BROADCAST_WEB3_TRANSACTION_REQUESTED; -} -interface BroadcastTransactionSucceededAction { - type: TypeKeys.BROADCAST_TRANSACTION_SUCCEEDED; - payload: { indexingHash: string; broadcastedHash: string }; -} -interface BroadcastTransactionQueuedAction { - type: TypeKeys.BROADCAST_TRANSACTION_QUEUED; - payload: { indexingHash: string; serializedTransaction: Buffer }; -} -interface BroadcastTransactionFailedAction { - type: TypeKeys.BROADCAST_TRASACTION_FAILED; - payload: { indexingHash: string }; -} -type BroadcastAction = - | BroadcastLocalTransactionRequestedAction - | BroadcastTransactionSucceededAction - | BroadcastWeb3TransactionRequestedAction - | BroadcastTransactionQueuedAction - | BroadcastTransactionFailedAction; - -export { - BroadcastLocalTransactionRequestedAction, - BroadcastTransactionSucceededAction, - BroadcastWeb3TransactionRequestedAction, - BroadcastTransactionQueuedAction, - BroadcastTransactionFailedAction, - BroadcastAction -}; diff --git a/common/actions/transaction/actionTypes/current.ts b/common/actions/transaction/actionTypes/current.ts deleted file mode 100644 index 643022c6..00000000 --- a/common/actions/transaction/actionTypes/current.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { TypeKeys } from '../constants'; - -/* user input */ - -interface SetCurrentValueAction { - type: TypeKeys.CURRENT_VALUE_SET; - payload: string; -} - -interface SetCurrentToAction { - type: TypeKeys.CURRENT_TO_SET; - payload: string; -} - -type CurrentAction = SetCurrentValueAction | SetCurrentToAction; - -export { SetCurrentValueAction, SetCurrentToAction, CurrentAction }; diff --git a/common/actions/transaction/actionTypes/fields.ts b/common/actions/transaction/actionTypes/fields.ts deleted file mode 100644 index a4183a94..00000000 --- a/common/actions/transaction/actionTypes/fields.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { TypeKeys } from 'actions/transaction/constants'; -import { Wei, Data, Address, Nonce } from 'libs/units'; - -/* User Input */ -interface InputGasLimitAction { - type: TypeKeys.GAS_LIMIT_INPUT; - payload: string; -} -interface InputGasPriceAction { - type: TypeKeys.GAS_PRICE_INPUT; - payload: string; -} -interface InputGasPriceIntentAction { - type: TypeKeys.GAS_PRICE_INPUT_INTENT; - payload: string; -} -interface InputDataAction { - type: TypeKeys.DATA_FIELD_INPUT; - payload: string; -} -interface InputNonceAction { - type: TypeKeys.NONCE_INPUT; - payload: string; -} - -/*Field Actions -- Reducer input*/ - -// We can compute field validity by checking if the value is null - -interface SetGasLimitFieldAction { - type: TypeKeys.GAS_LIMIT_FIELD_SET; - payload: { - raw: string; - value: Wei | null; - }; -} - -interface SetGasPriceFieldAction { - type: TypeKeys.GAS_PRICE_FIELD_SET; - payload: { - raw: string; - value: Wei | null; - }; -} - -interface SetDataFieldAction { - type: TypeKeys.DATA_FIELD_SET; - payload: { - raw: string; - value: Data | null; - }; -} - -interface SetToFieldAction { - type: TypeKeys.TO_FIELD_SET; - payload: { - raw: string; - value: Address | null; - }; -} - -interface SetNonceFieldAction { - type: TypeKeys.NONCE_FIELD_SET; - payload: { - raw: string; - value: Nonce | null; - }; -} - -interface SetValueFieldAction { - type: TypeKeys.VALUE_FIELD_SET; - payload: { - raw: string; - value: Wei | null; - }; -} - -type InputFieldAction = InputNonceAction | InputGasLimitAction | InputDataAction; - -type FieldAction = - | SetGasLimitFieldAction - | SetDataFieldAction - | SetToFieldAction - | SetNonceFieldAction - | SetValueFieldAction - | SetGasPriceFieldAction; - -export { - InputGasLimitAction, - InputGasPriceAction, - InputGasPriceIntentAction, - InputDataAction, - InputNonceAction, - SetGasLimitFieldAction, - SetDataFieldAction, - SetToFieldAction, - SetNonceFieldAction, - SetValueFieldAction, - FieldAction, - InputFieldAction, - SetGasPriceFieldAction -}; diff --git a/common/actions/transaction/actionTypes/index.ts b/common/actions/transaction/actionTypes/index.ts deleted file mode 100644 index 3eb256de..00000000 --- a/common/actions/transaction/actionTypes/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './actionTypes'; diff --git a/common/actions/transaction/actionTypes/meta.ts b/common/actions/transaction/actionTypes/meta.ts deleted file mode 100644 index 93156a81..00000000 --- a/common/actions/transaction/actionTypes/meta.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { TypeKeys } from 'actions/transaction/constants'; -import { Address, TokenValue } from 'libs/units'; -/*Meta Actions*/ - -interface SetTokenToMetaAction { - type: TypeKeys.TOKEN_TO_META_SET; - payload: { - raw: string; - value: Address | null; - }; -} - -interface SetUnitMetaAction { - type: TypeKeys.UNIT_META_SET; - payload: string; -} - -interface SetTokenValueMetaAction { - type: TypeKeys.TOKEN_VALUE_META_SET; - payload: { - raw: string; - value: TokenValue | null; - }; -} - -interface SetAsContractInteractionAction { - type: TypeKeys.IS_CONTRACT_INTERACTION; -} - -interface SetAsViewAndSendAction { - type: TypeKeys.IS_VIEW_AND_SEND; -} - -type TransactionMetaAction = SetUnitMetaAction | SetTokenValueMetaAction | SetTokenToMetaAction; -type TransactionTypeMetaAction = SetAsContractInteractionAction | SetAsViewAndSendAction; - -type MetaAction = TransactionMetaAction | TransactionTypeMetaAction; - -export { - TransactionMetaAction, - TransactionTypeMetaAction, - MetaAction, - SetUnitMetaAction, - SetTokenToMetaAction, - SetTokenValueMetaAction, - SetAsContractInteractionAction, - SetAsViewAndSendAction -}; diff --git a/common/actions/transaction/actionTypes/network.ts b/common/actions/transaction/actionTypes/network.ts deleted file mode 100644 index ac660fa2..00000000 --- a/common/actions/transaction/actionTypes/network.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { TypeKeys } from 'actions/transaction/constants'; -import { IHexStrTransaction } from 'libs/transaction'; -/* Network actions */ -interface EstimateGasRequestedAction { - type: TypeKeys.ESTIMATE_GAS_REQUESTED; - payload: Partial; -} -interface EstimateGasSucceededAction { - type: TypeKeys.ESTIMATE_GAS_SUCCEEDED; -} -interface EstimateGasFailedAction { - type: TypeKeys.ESTIMATE_GAS_FAILED; -} -interface EstimateGasTimeoutAction { - type: TypeKeys.ESTIMATE_GAS_TIMEDOUT; -} -interface GetFromRequestedAction { - type: TypeKeys.GET_FROM_REQUESTED; -} -interface GetFromSucceededAction { - type: TypeKeys.GET_FROM_SUCCEEDED; - payload: string; -} -interface GetFromFailedAction { - type: TypeKeys.GET_FROM_FAILED; -} -interface GetNonceRequestedAction { - type: TypeKeys.GET_NONCE_REQUESTED; -} -interface GetNonceSucceededAction { - type: TypeKeys.GET_NONCE_SUCCEEDED; - payload: string; -} -interface GetNonceFailedAction { - type: TypeKeys.GET_NONCE_FAILED; -} - -type NetworkAction = - | EstimateGasFailedAction - | EstimateGasRequestedAction - | EstimateGasSucceededAction - | EstimateGasTimeoutAction - | GetFromRequestedAction - | GetFromSucceededAction - | GetFromFailedAction - | GetNonceRequestedAction - | GetNonceSucceededAction - | GetNonceFailedAction; - -export { - EstimateGasRequestedAction, - EstimateGasSucceededAction, - EstimateGasFailedAction, - EstimateGasTimeoutAction, - GetFromRequestedAction, - GetFromSucceededAction, - GetFromFailedAction, - GetNonceRequestedAction, - GetNonceSucceededAction, - GetNonceFailedAction, - NetworkAction -}; diff --git a/common/actions/transaction/actionTypes/sendEverything.ts b/common/actions/transaction/actionTypes/sendEverything.ts deleted file mode 100644 index ff4c6bfb..00000000 --- a/common/actions/transaction/actionTypes/sendEverything.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { TypeKeys } from 'actions/transaction'; - -interface SendEverythingRequestedAction { - type: TypeKeys.SEND_EVERYTHING_REQUESTED; -} -interface SendEverythingSucceededAction { - type: TypeKeys.SEND_EVERYTHING_SUCCEEDED; -} -interface SendEverythingFailedAction { - type: TypeKeys.SEND_EVERYTHING_FAILED; -} - -type SendEverythingAction = - | SendEverythingRequestedAction - | SendEverythingSucceededAction - | SendEverythingFailedAction; - -export { - SendEverythingAction, - SendEverythingSucceededAction, - SendEverythingFailedAction, - SendEverythingRequestedAction -}; diff --git a/common/actions/transaction/actionTypes/sign.ts b/common/actions/transaction/actionTypes/sign.ts deleted file mode 100644 index f9bf5509..00000000 --- a/common/actions/transaction/actionTypes/sign.ts +++ /dev/null @@ -1,40 +0,0 @@ -import EthTx from 'ethereumjs-tx'; -import { TypeKeys } from 'actions/transaction/constants'; - -/* - * Difference between the web3/local is that a local sign will actually sign the tx - * While a web3 sign just gathers the rest of the nessesary parameters of the ethereum tx - * to do the sign + broadcast in 1 step later on - */ - -/* Signing / Async actions */ -interface SignTransactionRequestedAction { - type: TypeKeys.SIGN_TRANSACTION_REQUESTED; - payload: EthTx; -} -interface SignLocalTransactionSucceededAction { - type: TypeKeys.SIGN_LOCAL_TRANSACTION_SUCCEEDED; - payload: { signedTransaction: Buffer; indexingHash: string; noVerify?: boolean }; // dont verify against fields, for pushTx -} - -interface SignWeb3TransactionSucceededAction { - type: TypeKeys.SIGN_WEB3_TRANSACTION_SUCCEEDED; - payload: { transaction: Buffer; indexingHash: string; noVerify?: boolean }; -} -interface SignTransactionFailedAction { - type: TypeKeys.SIGN_TRANSACTION_FAILED; -} - -type SignAction = - | SignTransactionRequestedAction - | SignLocalTransactionSucceededAction - | SignWeb3TransactionSucceededAction - | SignTransactionFailedAction; - -export { - SignTransactionRequestedAction, - SignLocalTransactionSucceededAction, - SignWeb3TransactionSucceededAction, - SignTransactionFailedAction, - SignAction -}; diff --git a/common/actions/transaction/actionTypes/swap.ts b/common/actions/transaction/actionTypes/swap.ts deleted file mode 100644 index 6e7f338a..00000000 --- a/common/actions/transaction/actionTypes/swap.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { TypeKeys } from 'actions/transaction/constants'; -import { - SetToFieldAction, - SetValueFieldAction, - SetTokenToMetaAction, - SetTokenValueMetaAction, - SetDataFieldAction -} from 'actions/transaction'; - -/* Swapping actions */ -interface SwapTokenToEtherAction { - type: TypeKeys.TOKEN_TO_ETHER_SWAP; - payload: { - to: SetToFieldAction['payload']; - value: SetValueFieldAction['payload']; - decimal: number; - }; -} -interface SwapEtherToTokenAction { - type: TypeKeys.ETHER_TO_TOKEN_SWAP; - payload: { - to: SetToFieldAction['payload']; - data: SetDataFieldAction['payload']; - tokenTo: SetTokenToMetaAction['payload']; - tokenValue: SetTokenValueMetaAction['payload']; - decimal: number; - }; -} -interface SwapTokenToTokenAction { - type: TypeKeys.TOKEN_TO_TOKEN_SWAP; - payload: { - to: SetToFieldAction['payload']; - data: SetDataFieldAction['payload']; - tokenValue: SetTokenValueMetaAction['payload']; - decimal: number; - }; -} -type SwapAction = SwapEtherToTokenAction | SwapTokenToEtherAction | SwapTokenToTokenAction; - -export { SwapTokenToEtherAction, SwapEtherToTokenAction, SwapAction, SwapTokenToTokenAction }; diff --git a/common/actions/transaction/constants.ts b/common/actions/transaction/constants.ts deleted file mode 100644 index 1add2622..00000000 --- a/common/actions/transaction/constants.ts +++ /dev/null @@ -1,59 +0,0 @@ -export enum TypeKeys { - ESTIMATE_GAS_REQUESTED = 'ESTIMATE_GAS_REQUESTED', - ESTIMATE_GAS_SUCCEEDED = 'ESTIMATE_GAS_SUCCEEDED', - ESTIMATE_GAS_FAILED = 'ESTIMATE_GAS_FAILED', - ESTIMATE_GAS_TIMEDOUT = 'ESTIMATE_GAS_TIMEDOUT', - - GET_FROM_REQUESTED = 'GET_FROM_REQUESTED', - GET_FROM_SUCCEEDED = 'GET_FROM_SUCCEEDED', - GET_FROM_FAILED = 'GET_FROM_FAILED', - - GET_NONCE_REQUESTED = 'GET_NONCE_REQUESTED', - GET_NONCE_SUCCEEDED = 'GET_NONCE_SUCCEEDED', - GET_NONCE_FAILED = 'GET_NONCE_FAILED', - - SIGN_TRANSACTION_REQUESTED = 'SIGN_TRANSACTION_REQUESTED', - SIGN_WEB3_TRANSACTION_SUCCEEDED = 'SIGN_WEB3_TRANSACTION_SUCCEEDED', - SIGN_LOCAL_TRANSACTION_SUCCEEDED = 'SIGN_LOCAL_TRANSACTION_SUCCEEDED', - SIGN_TRANSACTION_FAILED = 'SIGN_TRANSACTION_FAILED', - - BROADCAST_WEB3_TRANSACTION_REQUESTED = 'BROADCAST_WEB3_TRANSACTION_REQUESTED', - BROADCAST_TRANSACTION_SUCCEEDED = 'BROADCAST_TRANSACTION_SUCCEEDED', - BROADCAST_LOCAL_TRANSACTION_REQUESTED = 'BROADCAST_LOCAL_TRANSACTION_REQUESTED', - BROADCAST_TRANSACTION_QUEUED = 'BROADCAST_TRANSACTION_QUEUED', - BROADCAST_TRASACTION_FAILED = 'BROADCAST_TRASACTION_FAILED', - - CURRENT_VALUE_SET = 'CURRENT_VALUE_SET', - CURRENT_TO_SET = 'CURRENT_TO_SET', - - DATA_FIELD_INPUT = 'DATA_FIELD_INPUT', - GAS_LIMIT_INPUT = 'GAS_LIMIT_INPUT', - GAS_PRICE_INPUT = 'GAS_PRICE_INPUT', - GAS_PRICE_INPUT_INTENT = 'GAS_PRICE_INPUT_INTENT', - NONCE_INPUT = 'NONCE_INPUT', - - DATA_FIELD_SET = 'DATA_FIELD_SET', - GAS_LIMIT_FIELD_SET = 'GAS_LIMIT_FIELD_SET', - TO_FIELD_SET = 'TO_FIELD_SET', - VALUE_FIELD_SET = 'VALUE_FIELD_SET', - NONCE_FIELD_SET = 'NONCE_FIELD_SET', - GAS_PRICE_FIELD_SET = 'GAS_PRICE_FIELD_SET', - - TOKEN_TO_META_SET = 'TOKEN_TO_META_SET', - UNIT_META_SET = 'UNIT_META_SET', - TOKEN_VALUE_META_SET = 'TOKEN_VALUE_META_SET', - - TOKEN_TO_ETHER_SWAP = 'TOKEN_TO_ETHER_SWAP', - ETHER_TO_TOKEN_SWAP = 'ETHER_TO_TOKEN_SWAP', - TOKEN_TO_TOKEN_SWAP = 'TOKEN_TO_TOKEN_SWAP', - - SEND_EVERYTHING_REQUESTED = 'SEND_EVERYTHING_REQUESTED', - SEND_EVERYTHING_SUCCEEDED = 'SEND_EVERYTHING_SUCCEEDED', - SEND_EVERYTHING_FAILED = 'SEND_EVERYTHING_FAILED', - - IS_CONTRACT_INTERACTION = 'IS_CONTRACT_INTERACTION', - IS_VIEW_AND_SEND = 'IS_VIEW_AND_SEND', - - RESET_REQUESTED = 'TRANSACTION_RESET_REQUESTED', - RESET_SUCCESSFUL = 'TRANSACTION_RESET_SUCCESSFUL' -} diff --git a/common/actions/transaction/index.ts b/common/actions/transaction/index.ts deleted file mode 100644 index d5122d97..00000000 --- a/common/actions/transaction/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './actionCreators'; -export * from './constants'; -export * from './actionTypes'; diff --git a/common/actions/transactions/actionCreators.ts b/common/actions/transactions/actionCreators.ts deleted file mode 100644 index 48c40ef2..00000000 --- a/common/actions/transactions/actionCreators.ts +++ /dev/null @@ -1,35 +0,0 @@ -import * as interfaces from './actionTypes'; -import { TypeKeys } from './constants'; - -export type TFetchTransactionData = typeof fetchTransactionData; -export function fetchTransactionData(txhash: string): interfaces.FetchTransactionDataAction { - return { - type: TypeKeys.TRANSACTIONS_FETCH_TRANSACTION_DATA, - payload: txhash - }; -} - -export type TSetTransactionData = typeof setTransactionData; -export function setTransactionData( - payload: interfaces.SetTransactionDataAction['payload'] -): interfaces.SetTransactionDataAction { - return { - type: TypeKeys.TRANSACTIONS_SET_TRANSACTION_DATA, - payload - }; -} - -export type TResetTransactionData = typeof resetTransactionData; -export function resetTransactionData(): interfaces.ResetTransactionDataAction { - return { type: TypeKeys.TRANSACTIONS_RESET_TRANSACTION_DATA }; -} - -export type TAddRecentTransaction = typeof addRecentTransaction; -export function addRecentTransaction( - payload: interfaces.AddRecentTransactionAction['payload'] -): interfaces.AddRecentTransactionAction { - return { - type: TypeKeys.TRANSACTIONS_ADD_RECENT_TRANSACTION, - payload - }; -} diff --git a/common/actions/transactions/actionTypes.ts b/common/actions/transactions/actionTypes.ts deleted file mode 100644 index fd7686b2..00000000 --- a/common/actions/transactions/actionTypes.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { TypeKeys } from './constants'; -import { SavedTransaction, TransactionData, TransactionReceipt } from 'types/transactions'; - -export interface FetchTransactionDataAction { - type: TypeKeys.TRANSACTIONS_FETCH_TRANSACTION_DATA; - payload: string; -} - -export interface SetTransactionDataAction { - type: TypeKeys.TRANSACTIONS_SET_TRANSACTION_DATA; - payload: { - txhash: string; - data: TransactionData | null; - receipt: TransactionReceipt | null; - error: string | null; - }; -} - -export interface ResetTransactionDataAction { - type: TypeKeys.TRANSACTIONS_RESET_TRANSACTION_DATA; -} - -export interface AddRecentTransactionAction { - type: TypeKeys.TRANSACTIONS_ADD_RECENT_TRANSACTION; - payload: SavedTransaction; -} - -/*** Union Type ***/ -export type TransactionsAction = - | FetchTransactionDataAction - | SetTransactionDataAction - | ResetTransactionDataAction - | AddRecentTransactionAction; diff --git a/common/actions/transactions/constants.ts b/common/actions/transactions/constants.ts deleted file mode 100644 index a1834597..00000000 --- a/common/actions/transactions/constants.ts +++ /dev/null @@ -1,7 +0,0 @@ -export enum TypeKeys { - TRANSACTIONS_FETCH_TRANSACTION_DATA = 'TRANSACTIONS_FETCH_TRANSACTION_DATA', - TRANSACTIONS_SET_TRANSACTION_DATA = 'TRANSACTIONS_SET_TRANSACTION_DATA', - TRANSACTIONS_SET_TRANSACTION_ERROR = 'TRANSACTIONS_SET_TRANSACTION_ERROR', - TRANSACTIONS_RESET_TRANSACTION_DATA = 'TRANSACTIONS_RESET_TRANSACTION_DATA', - TRANSACTIONS_ADD_RECENT_TRANSACTION = 'TRANSACTIONS_ADD_RECENT_TRANSACTION' -} diff --git a/common/actions/transactions/index.ts b/common/actions/transactions/index.ts deleted file mode 100644 index 51fcd517..00000000 --- a/common/actions/transactions/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './actionCreators'; -export * from './actionTypes'; -export * from './constants'; diff --git a/common/actions/wallet/actionTypes.ts b/common/actions/wallet/actionTypes.ts deleted file mode 100644 index d8c37877..00000000 --- a/common/actions/wallet/actionTypes.ts +++ /dev/null @@ -1,156 +0,0 @@ -import { Wei, TokenValue } from 'libs/units'; -import { IWallet, WalletConfig } from 'libs/wallet'; -import { TypeKeys } from './constants'; - -/*** Unlock Private Key ***/ -export interface PrivateKeyUnlockParams { - key: string; - password: string; -} - -export interface UnlockPrivateKeyAction { - type: TypeKeys.WALLET_UNLOCK_PRIVATE_KEY; - payload: PrivateKeyUnlockParams; -} -export interface UnlockMnemonicAction { - type: TypeKeys.WALLET_UNLOCK_MNEMONIC; - payload: MnemonicUnlockParams; -} - -export interface UnlockWeb3Action { - type: TypeKeys.WALLET_UNLOCK_WEB3; -} - -/*** Set Wallet ***/ -export interface SetWalletAction { - type: TypeKeys.WALLET_SET; - payload: IWallet; -} - -/*** Reset Wallet ***/ -export interface ResetWalletAction { - type: TypeKeys.WALLET_RESET; -} - -export interface SetWalletPendingAction { - type: TypeKeys.WALLET_SET_PENDING; - payload: boolean; -} - -/*** Set Balance ***/ -export interface SetBalancePendingAction { - type: TypeKeys.WALLET_SET_BALANCE_PENDING; -} -export interface SetBalanceFullfilledAction { - type: TypeKeys.WALLET_SET_BALANCE_FULFILLED; - payload: Wei; -} -export interface SetBalanceRejectedAction { - type: TypeKeys.WALLET_SET_BALANCE_REJECTED; -} - -/*** Set Token Balance ***/ -export interface SetTokenBalancesPendingAction { - type: TypeKeys.WALLET_SET_TOKEN_BALANCES_PENDING; -} - -export interface SetTokenBalancesFulfilledAction { - type: TypeKeys.WALLET_SET_TOKEN_BALANCES_FULFILLED; - payload: { - [key: string]: { - balance: TokenValue; - error: string | null; - }; - }; -} - -export interface SetTokenBalancesRejectedAction { - type: TypeKeys.WALLET_SET_TOKEN_BALANCES_REJECTED; -} - -export interface SetTokenBalancePendingAction { - type: TypeKeys.WALLET_SET_TOKEN_BALANCE_PENDING; - payload: { tokenSymbol: string }; -} - -export interface SetTokenBalanceFulfilledAction { - type: TypeKeys.WALLET_SET_TOKEN_BALANCE_FULFILLED; - payload: { - [key: string]: { - balance: TokenValue; - error: string | null; - }; - }; -} - -export interface SetTokenBalanceRejectedAction { - type: TypeKeys.WALLET_SET_TOKEN_BALANCE_REJECTED; -} - -export interface ScanWalletForTokensAction { - type: TypeKeys.WALLET_SCAN_WALLET_FOR_TOKENS; - payload: IWallet; -} - -export interface SetWalletTokensAction { - type: TypeKeys.WALLET_SET_WALLET_TOKENS; - payload: string[]; -} - -/*** Unlock Mnemonic ***/ -export interface MnemonicUnlockParams { - phrase: string; - pass: string; - path: string; - address: string; -} - -/*** Unlock Keystore File ***/ -export interface KeystoreUnlockParams { - file: string; - password: string; -} - -export interface UnlockKeystoreAction { - type: TypeKeys.WALLET_UNLOCK_KEYSTORE; - payload: KeystoreUnlockParams; -} - -export interface SetWalletConfigAction { - type: TypeKeys.WALLET_SET_CONFIG; - payload: WalletConfig; -} - -export interface SetPasswordPendingAction { - type: TypeKeys.WALLET_SET_PASSWORD_PENDING; -} - -export interface RefreshAccountBalanceAction { - type: TypeKeys.WALLET_REFRESH_ACCOUNT_BALANCE; -} - -export interface RefreshTokenBalancesAction { - type: TypeKeys.WALLET_REFRESH_TOKEN_BALANCES; -} - -/*** Union Type ***/ -export type WalletAction = - | UnlockPrivateKeyAction - | SetWalletAction - | SetWalletPendingAction - | ResetWalletAction - | SetBalancePendingAction - | SetBalanceFullfilledAction - | SetBalanceRejectedAction - | SetTokenBalancesPendingAction - | SetTokenBalancesFulfilledAction - | SetTokenBalancesRejectedAction - | SetTokenBalancePendingAction - | SetTokenBalanceFulfilledAction - | SetTokenBalanceRejectedAction - | ScanWalletForTokensAction - | SetWalletTokensAction - | SetWalletConfigAction - | SetPasswordPendingAction - | RefreshAccountBalanceAction - | RefreshTokenBalancesAction; diff --git a/common/actions/wallet/constants.ts b/common/actions/wallet/constants.ts deleted file mode 100644 index 59332b8d..00000000 --- a/common/actions/wallet/constants.ts +++ /dev/null @@ -1,25 +0,0 @@ -export enum TypeKeys { - WALLET_UNLOCK_PRIVATE_KEY = 'WALLET_UNLOCK_PRIVATE_KEY', - WALLET_UNLOCK_KEYSTORE = 'WALLET_UNLOCK_KEYSTORE', - WALLET_UNLOCK_MNEMONIC = 'WALLET_UNLOCK_MNEMONIC', - WALLET_UNLOCK_WEB3 = 'WALLET_UNLOCK_WEB3', - WALLET_SET = 'WALLET_SET', - WALLET_SET_BALANCE_PENDING = 'WALLET_SET_BALANCE_PENDING', - WALLET_SET_BALANCE_FULFILLED = 'WALLET_SET_BALANCE_FULFILLED', - WALLET_SET_BALANCE_REJECTED = 'WALLET_SET_BALANCE_REJECTED', - WALLET_SET_TOKEN_BALANCES_PENDING = 'WALLET_SET_TOKEN_BALANCES_PENDING', - WALLET_SET_TOKEN_BALANCES_FULFILLED = 'WALLET_SET_TOKEN_BALANCES_FULFILLED', - WALLET_SET_TOKEN_BALANCES_REJECTED = 'WALLET_SET_TOKEN_BALANCES_REJECTED', - WALLET_SET_PENDING = 'WALLET_SET_PENDING', - WALLET_SET_NOT_PENDING = 'WALLET_SET_NOT_PENDING', - WALLET_SET_TOKEN_BALANCE_PENDING = 'WALLET_SET_TOKEN_BALANCE_PENDING', - WALLET_SET_TOKEN_BALANCE_FULFILLED = 'WALLET_SET_TOKEN_BALANCE_FULFILLED', - WALLET_SET_TOKEN_BALANCE_REJECTED = 'WALLET_SET_TOKEN_BALANCE_REJECTED', - WALLET_SCAN_WALLET_FOR_TOKENS = 'WALLET_SCAN_WALLET_FOR_TOKENS', - WALLET_SET_WALLET_TOKENS = 'WALLET_SET_WALLET_TOKENS', - WALLET_SET_CONFIG = 'WALLET_SET_CONFIG', - WALLET_RESET = 'WALLET_RESET', - WALLET_SET_PASSWORD_PENDING = 'WALLET_SET_PASSWORD_PENDING', - WALLET_REFRESH_ACCOUNT_BALANCE = 'WALLET_REFRESH_ACCOUNT_BALANCE', - WALLET_REFRESH_TOKEN_BALANCES = 'WALLET_REFRESH_TOKEN_BALANCES' -} diff --git a/common/actions/wallet/index.ts b/common/actions/wallet/index.ts deleted file mode 100644 index fee14683..00000000 --- a/common/actions/wallet/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './constants'; -export * from './actionTypes'; -export * from './actionCreators'; diff --git a/common/api/gas.ts b/common/api/gas.ts index 3bdd3b70..a111db9d 100644 --- a/common/api/gas.ts +++ b/common/api/gas.ts @@ -1,6 +1,7 @@ -import { checkHttpStatus, parseJSON } from './utils'; import { Omit } from 'react-redux'; +import { checkHttpStatus, parseJSON } from './utils'; + const MAX_GAS_FAST = 250; interface RawGasEstimates { diff --git a/common/api/rates.ts b/common/api/rates.ts index 5c7dcfff..ae58b9ff 100644 --- a/common/api/rates.ts +++ b/common/api/rates.ts @@ -1,4 +1,5 @@ import { handleJSONResponse } from 'api/utils'; + interface IRateSymbols { symbols: { all: TAllSymbols; diff --git a/common/assets/images/wallets/file.svg b/common/assets/images/wallets/file.svg new file mode 100644 index 00000000..31f2a29e --- /dev/null +++ b/common/assets/images/wallets/file.svg @@ -0,0 +1,3 @@ + + + diff --git a/common/assets/images/wallets/hardware.svg b/common/assets/images/wallets/hardware.svg new file mode 100644 index 00000000..0821465f --- /dev/null +++ b/common/assets/images/wallets/hardware.svg @@ -0,0 +1,12 @@ + + + + Artboard + Created with Sketch. + + + + + + + \ No newline at end of file diff --git a/common/components/AddressBookTable.tsx b/common/components/AddressBookTable.tsx index c01c5f51..1667b5f4 100644 --- a/common/components/AddressBookTable.tsx +++ b/common/components/AddressBookTable.tsx @@ -1,37 +1,31 @@ import React from 'react'; import { connect, MapStateToProps } from 'react-redux'; import classnames from 'classnames'; -import { AppState } from 'reducers'; + import translate, { translateRaw } from 'translations'; +import { AppState } from 'features/reducers'; +import { getChecksumAddressFn } from 'features/config'; import { - changeAddressLabelEntry, - TChangeAddressLabelEntry, - saveAddressLabelEntry, - TSaveAddressLabelEntry, - removeAddressLabelEntry, - TRemoveAddressLabelEntry -} from 'actions/addressBook'; -import { - getAddressLabels, - getLabelAddresses, - getAddressLabelRows, - getAddressBookTableEntry -} from 'selectors/addressBook'; + addressBookConstants, + addressBookActions, + addressBookSelectors +} from 'features/addressBook'; import { Input, Identicon } from 'components/ui'; import AddressBookTableRow from './AddressBookTableRow'; import './AddressBookTable.scss'; interface DispatchProps { - changeAddressLabelEntry: TChangeAddressLabelEntry; - saveAddressLabelEntry: TSaveAddressLabelEntry; - removeAddressLabelEntry: TRemoveAddressLabelEntry; + changeAddressLabelEntry: addressBookActions.TChangeAddressLabelEntry; + saveAddressLabelEntry: addressBookActions.TSaveAddressLabelEntry; + removeAddressLabelEntry: addressBookActions.TRemoveAddressLabelEntry; } interface StateProps { - rows: ReturnType; - entry: ReturnType; - addressLabels: ReturnType; - labelAddresses: ReturnType; + rows: ReturnType; + entry: ReturnType; + addressLabels: ReturnType; + labelAddresses: ReturnType; + toChecksumAddress: ReturnType; } type Props = DispatchProps & StateProps; @@ -44,8 +38,6 @@ interface State { labelBlurred: boolean; } -export const ADDRESS_BOOK_TABLE_ID: string = 'ADDRESS_BOOK_TABLE_ID'; - class AddressBookTable extends React.Component { public state: State = { editingRow: null, @@ -180,7 +172,7 @@ class AddressBookTable extends React.Component { this.labelInput.focus(); } - this.props.saveAddressLabelEntry(ADDRESS_BOOK_TABLE_ID); + this.props.saveAddressLabelEntry(addressBookConstants.ADDRESS_BOOK_TABLE_ID); if (!addressError && !labelError) { this.clearFieldStatuses(); @@ -200,7 +192,8 @@ class AddressBookTable extends React.Component { private makeLabelRow = (row: any, index: number) => { const { editingRow } = this.state; - const { id, address, label, temporaryLabel, labelError } = row; + const { id, label, temporaryLabel, labelError } = row; + const address = this.props.toChecksumAddress(row.address); const isEditing = index === editingRow; const onChange = (newLabel: string) => this.props.changeAddressLabelEntry({ @@ -262,7 +255,7 @@ class AddressBookTable extends React.Component { const label = entry.temporaryLabel || ''; this.props.changeAddressLabelEntry({ - id: ADDRESS_BOOK_TABLE_ID, + id: addressBookConstants.ADDRESS_BOOK_TABLE_ID, address, label }); @@ -287,7 +280,7 @@ class AddressBookTable extends React.Component { const label = e.target.value; this.props.changeAddressLabelEntry({ - id: ADDRESS_BOOK_TABLE_ID, + id: addressBookConstants.ADDRESS_BOOK_TABLE_ID, address, label }); @@ -305,16 +298,17 @@ class AddressBookTable extends React.Component { } const mapStateToProps: MapStateToProps = state => ({ - rows: getAddressLabelRows(state), - entry: getAddressBookTableEntry(state), - addressLabels: getAddressLabels(state), - labelAddresses: getLabelAddresses(state) + rows: addressBookSelectors.getAddressLabelRows(state), + entry: addressBookSelectors.getAddressBookTableEntry(state), + addressLabels: addressBookSelectors.getAddressLabels(state), + labelAddresses: addressBookSelectors.getLabelAddresses(state), + toChecksumAddress: getChecksumAddressFn(state) }); const mapDispatchToProps: DispatchProps = { - changeAddressLabelEntry, - saveAddressLabelEntry, - removeAddressLabelEntry + changeAddressLabelEntry: addressBookActions.changeAddressLabelEntry, + saveAddressLabelEntry: addressBookActions.saveAddressLabelEntry, + removeAddressLabelEntry: addressBookActions.removeAddressLabelEntry }; export default connect(mapStateToProps, mapDispatchToProps)(AddressBookTable); diff --git a/common/components/AddressBookTableRow.tsx b/common/components/AddressBookTableRow.tsx index 757fbad0..2804e1d6 100644 --- a/common/components/AddressBookTableRow.tsx +++ b/common/components/AddressBookTableRow.tsx @@ -1,6 +1,7 @@ import React from 'react'; -import translate, { translateRaw } from 'translations'; import noop from 'lodash/noop'; + +import translate, { translateRaw } from 'translations'; import { Input, Identicon } from 'components/ui'; interface Props { diff --git a/common/components/AddressField.tsx b/common/components/AddressField.tsx index 28029d4e..62af5f4d 100644 --- a/common/components/AddressField.tsx +++ b/common/components/AddressField.tsx @@ -1,22 +1,32 @@ import React from 'react'; -import { AddressFieldFactory } from './AddressFieldFactory'; +import { connect } from 'react-redux'; + import { donationAddressMap } from 'config'; import translate from 'translations'; +import { AppState } from 'features/reducers'; +import { getChecksumAddressFn } from 'features/config'; import { Input } from 'components/ui'; -import { toChecksumAddress } from 'ethereumjs-util'; +import { AddressFieldFactory } from './AddressFieldFactory'; -interface Props { +interface OwnProps { isReadOnly?: boolean; isSelfAddress?: boolean; isCheckSummed?: boolean; showLabelMatch?: boolean; } -export const AddressField: React.SFC = ({ +interface StateProps { + toChecksumAddress: ReturnType; +} + +type Props = OwnProps & StateProps; + +const AddressField: React.SFC = ({ isReadOnly, isSelfAddress, isCheckSummed, - showLabelMatch + showLabelMatch, + toChecksumAddress }) => ( = ({ )} /> ); + +export default connect((state: AppState): StateProps => ({ + toChecksumAddress: getChecksumAddressFn(state) +}))(AddressField); diff --git a/common/components/AddressFieldFactory/AddressFieldDropdown.tsx b/common/components/AddressFieldFactory/AddressFieldDropdown.tsx index 376d0cef..433361c8 100644 --- a/common/components/AddressFieldFactory/AddressFieldDropdown.tsx +++ b/common/components/AddressFieldFactory/AddressFieldDropdown.tsx @@ -1,20 +1,20 @@ import React from 'react'; import { connect } from 'react-redux'; -import { AppState } from 'reducers'; + import translate, { translateRaw } from 'translations'; -import { setCurrentTo, TSetCurrentTo } from 'actions/transaction'; -import { getLabelAddresses } from 'selectors/addressBook'; -import { getToRaw } from 'selectors/transaction/fields'; +import { AppState } from 'features/reducers'; +import { transactionActions, transactionSelectors } from 'features/transaction'; +import { addressBookSelectors } from 'features/addressBook'; import { Address, Identicon } from 'components/ui'; import './AddressFieldDropdown.scss'; interface StateProps { - labelAddresses: ReturnType; - currentTo: ReturnType; + labelAddresses: ReturnType; + currentTo: ReturnType; } interface DispatchProps { - setCurrentTo: TSetCurrentTo; + setCurrentTo: transactionActions.TSetCurrentTo; } type Props = StateProps & DispatchProps; @@ -158,8 +158,8 @@ class AddressFieldDropdown extends React.Component { export default connect( (state: AppState) => ({ - labelAddresses: getLabelAddresses(state), - currentTo: getToRaw(state) + labelAddresses: addressBookSelectors.getLabelAddresses(state), + currentTo: transactionSelectors.getToRaw(state) }), - { setCurrentTo } + { setCurrentTo: transactionActions.setCurrentTo } )(AddressFieldDropdown); diff --git a/common/components/AddressFieldFactory/AddressFieldFactory.tsx b/common/components/AddressFieldFactory/AddressFieldFactory.tsx index 83dc1ebc..625bb1a6 100644 --- a/common/components/AddressFieldFactory/AddressFieldFactory.tsx +++ b/common/components/AddressFieldFactory/AddressFieldFactory.tsx @@ -1,13 +1,14 @@ -import { Query } from 'components/renderCbs'; -import { setCurrentTo, TSetCurrentTo } from 'actions/transaction'; -import { AddressInputFactory } from './AddressInputFactory'; import React from 'react'; import { connect } from 'react-redux'; -import { ICurrentTo } from 'selectors/transaction'; + +import { ICurrentTo } from 'features/types'; +import { transactionActions } from 'features/transaction'; +import { Query } from 'components/renderCbs'; +import { AddressInputFactory } from './AddressInputFactory'; import './AddressFieldFactory.scss'; interface DispatchProps { - setCurrentTo: TSetCurrentTo; + setCurrentTo: transactionActions.TSetCurrentTo; } interface OwnProps { @@ -82,7 +83,9 @@ class AddressFieldFactoryClass extends React.Component { private setBlurTimeout = () => (this.goingToBlur = window.setTimeout(this.blur, 150)); } -const AddressFieldFactory = connect(null, { setCurrentTo })(AddressFieldFactoryClass); +const AddressFieldFactory = connect(null, { setCurrentTo: transactionActions.setCurrentTo })( + AddressFieldFactoryClass +); interface DefaultAddressFieldProps { isSelfAddress?: boolean; diff --git a/common/components/AddressFieldFactory/AddressInputFactory.tsx b/common/components/AddressFieldFactory/AddressInputFactory.tsx index 817a34ca..65189ed0 100644 --- a/common/components/AddressFieldFactory/AddressInputFactory.tsx +++ b/common/components/AddressFieldFactory/AddressInputFactory.tsx @@ -1,22 +1,18 @@ import React, { Component } from 'react'; -import { Identicon, Spinner } from 'components/ui'; -import { Query } from 'components/renderCbs'; -import { translateRaw } from 'translations'; -import { - ICurrentTo, - getCurrentTo, - isValidCurrentTo, - isCurrentToLabelEntry -} from 'selectors/transaction'; -import { getCurrentToLabel } from 'selectors/addressBook'; import { connect } from 'react-redux'; -import { AppState } from 'reducers'; -import { CallbackProps } from 'components/AddressFieldFactory'; import { addHexPrefix } from 'ethereumjs-util'; -import { getWalletInst } from 'selectors/wallet'; -import { getResolvingDomain } from 'selectors/ens'; + +import translate, { translateRaw } from 'translations'; import { isValidENSAddress } from 'libs/validators'; import { Address } from 'libs/units'; +import { ICurrentTo } from 'features/types'; +import { AppState } from 'features/reducers'; +import * as selectors from 'features/selectors'; +import { walletSelectors } from 'features/wallet'; +import { ensSelectors } from 'features/ens'; +import { Identicon, Spinner } from 'components/ui'; +import { Query } from 'components/renderCbs'; +import { CallbackProps } from 'components/AddressFieldFactory'; import AddressFieldDropdown from './AddressFieldDropdown'; import './AddressInputFactory.scss'; @@ -44,7 +40,8 @@ const ENSStatus: React.SFC<{ isLoading: boolean; ensAddress: string; rawAddress: rawAddress }) => { const isENS = isValidENSAddress(ensAddress); - const text = 'Loading ENS address...'; + const text = translate('LOADING_ENS_ADDRESS'); + if (isLoading) { return ( @@ -117,21 +114,21 @@ class AddressInputFactoryClass extends Component { export const AddressInputFactory = connect((state: AppState, ownProps: OwnProps) => { let currentTo: ICurrentTo; if (ownProps.isSelfAddress) { - const wallet = getWalletInst(state); + const wallet = walletSelectors.getWalletInst(state); const addr = wallet ? wallet.getAddressString() : ''; currentTo = { raw: addr, value: Address(addr) }; } else { - currentTo = getCurrentTo(state); + currentTo = selectors.getCurrentTo(state); } return { currentTo, - label: getCurrentToLabel(state), - isResolving: getResolvingDomain(state), - isValid: isValidCurrentTo(state), - isLabelEntry: isCurrentToLabelEntry(state) + label: selectors.getCurrentToLabel(state), + isResolving: ensSelectors.getResolvingDomain(state), + isValid: selectors.isValidCurrentTo(state), + isLabelEntry: selectors.isCurrentToLabelEntry(state) }; })(AddressInputFactoryClass); diff --git a/common/components/AmountField.tsx b/common/components/AmountField.tsx index 45d09ede..d104f183 100644 --- a/common/components/AmountField.tsx +++ b/common/components/AmountField.tsx @@ -1,8 +1,9 @@ import React from 'react'; -import { AmountFieldFactory } from './AmountFieldFactory'; -import { UnitDropDown, SendEverything } from 'components'; + import translate from 'translations'; +import { UnitDropDown, SendEverything } from 'components'; import { Input } from 'components/ui'; +import { AmountFieldFactory } from './AmountFieldFactory'; interface Props { hasUnitDropdown?: boolean; diff --git a/common/components/AmountFieldFactory/AmountFieldFactory.tsx b/common/components/AmountFieldFactory/AmountFieldFactory.tsx index 44457faf..15f4849a 100644 --- a/common/components/AmountFieldFactory/AmountFieldFactory.tsx +++ b/common/components/AmountFieldFactory/AmountFieldFactory.tsx @@ -1,9 +1,10 @@ import React, { Component } from 'react'; -import { Query } from 'components/renderCbs'; -import { setCurrentValue, TSetCurrentValue } from 'actions/transaction'; import { connect } from 'react-redux'; + +import { AppState } from 'features/reducers'; +import { transactionActions } from 'features/transaction'; +import { Query } from 'components/renderCbs'; import { AmountInput } from './AmountInputFactory'; -import { AppState } from 'reducers'; export interface CallbackProps { isValid: boolean; @@ -15,7 +16,7 @@ export interface CallbackProps { } interface DispatchProps { - setCurrentValue: TSetCurrentValue; + setCurrentValue: transactionActions.TSetCurrentValue; } interface OwnProps { @@ -43,7 +44,9 @@ class AmountFieldClass extends Component { }; } -const AmountField = connect(null, { setCurrentValue })(AmountFieldClass); +const AmountField = connect(null, { setCurrentValue: transactionActions.setCurrentValue })( + AmountFieldClass +); interface DefaultAmountFieldProps { withProps(props: CallbackProps): React.ReactElement | null; diff --git a/common/components/AmountFieldFactory/AmountInputFactory.tsx b/common/components/AmountFieldFactory/AmountInputFactory.tsx index 1c52c476..0a1ac297 100644 --- a/common/components/AmountFieldFactory/AmountInputFactory.tsx +++ b/common/components/AmountFieldFactory/AmountInputFactory.tsx @@ -1,9 +1,11 @@ import React, { Component } from 'react'; -import { Query } from 'components/renderCbs'; -import { ICurrentValue, getCurrentValue, nonStandardTransaction } from 'selectors/transaction'; -import { AppState } from 'reducers'; import { connect } from 'react-redux'; + +import { AppState } from 'features/reducers'; +import { ICurrentValue } from 'features/types'; +import { getCurrentValue, nonStandardTransaction } from 'features/selectors'; import { CallbackProps } from 'components/AmountFieldFactory'; +import { Query } from 'components/renderCbs'; interface OwnProps { onChange(ev: React.FormEvent): void; diff --git a/common/components/AppAlphaNotice/AlphaNotice.tsx b/common/components/AppAlphaNotice/AlphaNotice.tsx index 6c1c90be..9dddd3a1 100644 --- a/common/components/AppAlphaNotice/AlphaNotice.tsx +++ b/common/components/AppAlphaNotice/AlphaNotice.tsx @@ -1,7 +1,8 @@ import React from 'react'; import moment from 'moment'; -import { NewTabLink } from 'components/ui'; + import { discordURL, APP_ALPHA_EXPIRATION } from 'config'; +import { NewTabLink } from 'components/ui'; import './AlphaNotice.scss'; interface State { diff --git a/common/components/AppAlphaNotice/AppExpired.tsx b/common/components/AppAlphaNotice/AppExpired.tsx index b241d5e6..a36a79c4 100644 --- a/common/components/AppAlphaNotice/AppExpired.tsx +++ b/common/components/AppAlphaNotice/AppExpired.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { NewTabLink } from 'components/ui'; import './AppExpired.scss'; diff --git a/common/components/AppAlphaNotice/index.tsx b/common/components/AppAlphaNotice/index.tsx index 538260e5..8a66179e 100644 --- a/common/components/AppAlphaNotice/index.tsx +++ b/common/components/AppAlphaNotice/index.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { APP_ALPHA_EXPIRATION } from 'config'; import AlphaNotice from './AlphaNotice'; import AppExpired from './AppExpired'; diff --git a/common/components/BalanceSidebar/AccountAddress.tsx b/common/components/BalanceSidebar/AccountAddress.tsx index 497dfc15..c8ce5471 100644 --- a/common/components/BalanceSidebar/AccountAddress.tsx +++ b/common/components/BalanceSidebar/AccountAddress.tsx @@ -1,28 +1,25 @@ import React from 'react'; import { connect, MapStateToProps } from 'react-redux'; import { CopyToClipboard } from 'react-copy-to-clipboard'; + import translate, { translateRaw } from 'translations'; -import { AppState } from 'reducers'; +import { AppState } from 'features/reducers'; import { - changeAddressLabelEntry, - TChangeAddressLabelEntry, - saveAddressLabelEntry, - TSaveAddressLabelEntry, - removeAddressLabelEntry, - TRemoveAddressLabelEntry -} from 'actions/addressBook'; -import { getAccountAddressEntry, getAddressLabels } from 'selectors/addressBook'; + addressBookConstants, + addressBookActions, + addressBookSelectors +} from 'features/addressBook'; import { Address, Identicon, Input } from 'components/ui'; interface StateProps { - entry: ReturnType; - addressLabels: ReturnType; + entry: ReturnType; + addressLabel: string; } interface DispatchProps { - changeAddressLabelEntry: TChangeAddressLabelEntry; - saveAddressLabelEntry: TSaveAddressLabelEntry; - removeAddressLabelEntry: TRemoveAddressLabelEntry; + changeAddressLabelEntry: addressBookActions.TChangeAddressLabelEntry; + saveAddressLabelEntry: addressBookActions.TSaveAddressLabelEntry; + removeAddressLabelEntry: addressBookActions.TRemoveAddressLabelEntry; } interface OwnProps { @@ -37,8 +34,6 @@ interface State { labelInputTouched: boolean; } -export const ACCOUNT_ADDRESS_ID: string = 'ACCOUNT_ADDRESS_ID'; - class AccountAddress extends React.Component { public state = { copied: false, @@ -65,13 +60,12 @@ class AccountAddress extends React.Component { } public render() { - const { address, addressLabels } = this.props; + const { address, addressLabel } = this.props; const { copied } = this.state; - const label = addressLabels[address]; const labelContent = this.generateLabelContent(); const labelButton = this.generateLabelButton(); const addressClassName = `AccountInfo-address-addr ${ - label ? 'AccountInfo-address-addr--small' : '' + addressLabel ? 'AccountInfo-address-addr--small' : '' }`; return ( @@ -89,13 +83,13 @@ class AccountAddress extends React.Component {
- {copied ? 'copied!' : 'copy address'} + {translateRaw(copied ? 'COPIED' : 'COPY_ADDRESS')}
-
+
{labelButton}
@@ -120,10 +114,9 @@ class AccountAddress extends React.Component { private setLabelInputRef = (node: HTMLInputElement) => (this.labelInput = node); private generateLabelContent = () => { - const { address, addressLabels, entry: { temporaryLabel, labelError } } = this.props; + const { addressLabel, entry: { temporaryLabel, labelError } } = this.props; const { editingLabel, labelInputTouched } = this.state; - const storedLabel = addressLabels[address]; - const newLabelSameAsPrevious = temporaryLabel === storedLabel; + const newLabelSameAsPrevious = temporaryLabel === addressLabel; const labelInputTouchedWithError = labelInputTouched && !newLabelSameAsPrevious && labelError; let labelContent = null; @@ -134,7 +127,7 @@ class AccountAddress extends React.Component { {
); } else { - labelContent = ( - - ); + labelContent = ; } return labelContent; }; private generateLabelButton = () => { - const { address, addressLabels } = this.props; + const { addressLabel } = this.props; const { editingLabel } = this.state; - const label = addressLabels[address]; const labelButton = editingLabel ? ( @@ -175,10 +163,10 @@ class AccountAddress extends React.Component { - {label ? translate('EDIT_LABEL') : translate('ADD_LABEL_9')} + {addressLabel ? translate('EDIT_LABEL') : translate('ADD_LABEL_9')} ); @@ -187,13 +175,12 @@ class AccountAddress extends React.Component { }; private handleBlur = () => { - const { address, addressLabels, entry: { id, label, temporaryLabel, labelError } } = this.props; - const storedLabel = addressLabels[address]; + const { address, addressLabel, entry: { id, label, temporaryLabel, labelError } } = this.props; this.clearTemporaryLabelTouched(); this.stopEditingLabel(); - if (temporaryLabel === storedLabel) { + if (temporaryLabel === addressLabel) { return; } @@ -230,7 +217,7 @@ class AccountAddress extends React.Component { const label = e.target.value; this.props.changeAddressLabelEntry({ - id: ACCOUNT_ADDRESS_ID, + id: addressBookConstants.ACCOUNT_ADDRESS_ID, address, label, isEditing: true @@ -255,15 +242,21 @@ class AccountAddress extends React.Component { private clearTemporaryLabelTouched = () => this.setState({ labelInputTouched: false }); } -const mapStateToProps: MapStateToProps = (state: AppState) => ({ - entry: getAccountAddressEntry(state), - addressLabels: getAddressLabels(state) -}); +const mapStateToProps: MapStateToProps = ( + state: AppState, + ownProps: OwnProps +) => { + const labelEntry = addressBookSelectors.getAddressLabelEntryFromAddress(state, ownProps.address); + return { + entry: addressBookSelectors.getAccountAddressEntry(state), + addressLabel: labelEntry ? labelEntry.label : '' + }; +}; const mapDispatchToProps: DispatchProps = { - changeAddressLabelEntry, - saveAddressLabelEntry, - removeAddressLabelEntry + changeAddressLabelEntry: addressBookActions.changeAddressLabelEntry, + saveAddressLabelEntry: addressBookActions.saveAddressLabelEntry, + removeAddressLabelEntry: addressBookActions.removeAddressLabelEntry }; export default connect( diff --git a/common/components/BalanceSidebar/AccountInfo.tsx b/common/components/BalanceSidebar/AccountInfo.tsx index b1169619..2dda2434 100644 --- a/common/components/BalanceSidebar/AccountInfo.tsx +++ b/common/components/BalanceSidebar/AccountInfo.tsx @@ -1,17 +1,17 @@ import React from 'react'; import { connect } from 'react-redux'; -import { toChecksumAddress } from 'ethereumjs-util'; -import { UnitDisplay, NewTabLink } from 'components/ui'; -import { IWallet, TrezorWallet, LedgerWallet, Balance } from 'libs/wallet'; -import translate, { translateRaw } from 'translations'; -import Spinner from 'components/ui/Spinner'; -import { getNetworkConfig, getOffline } from 'selectors/config'; -import { AppState } from 'reducers'; -import { NetworkConfig } from 'types/network'; -import { TRefreshAccountBalance, refreshAccountBalance } from 'actions/wallet'; + import { etherChainExplorerInst } from 'config/data'; -import './AccountInfo.scss'; +import translate, { translateRaw } from 'translations'; +import { IWallet, HardwareWallet, Balance } from 'libs/wallet'; +import { NetworkConfig } from 'types/network'; +import { AppState } from 'features/reducers'; +import { getNetworkConfig, getOffline, getChecksumAddressFn } from 'features/config'; +import { walletActions } from 'features/wallet'; +import Spinner from 'components/ui/Spinner'; +import { UnitDisplay, NewTabLink } from 'components/ui'; import AccountAddress from './AccountAddress'; +import './AccountInfo.scss'; interface OwnProps { wallet: IWallet; @@ -21,6 +21,7 @@ interface StateProps { balance: Balance; network: ReturnType; isOffline: ReturnType; + toChecksumAddress: ReturnType; } interface State { @@ -30,7 +31,7 @@ interface State { } interface DispatchProps { - refreshAccountBalance: TRefreshAccountBalance; + refreshAccountBalance: walletActions.TRefreshAccountBalance; } type Props = OwnProps & StateProps & DispatchProps; @@ -73,7 +74,7 @@ class AccountInfo extends React.Component { }; public render() { - const { network, isOffline, balance } = this.props; + const { network, isOffline, balance, toChecksumAddress, wallet } = this.props; const { address, showLongBalance, confirmAddr } = this.state; let blockExplorer; @@ -84,12 +85,11 @@ class AccountInfo extends React.Component { tokenExplorer = network.tokenExplorer; } - const wallet = this.props.wallet as LedgerWallet | TrezorWallet; return (
- {typeof wallet.displayAddress === 'function' && ( + {isHardwareWallet(wallet) && (
{ wallet .displayAddress() .then(() => this.toggleConfirmAddr()) - .catch(e => { + .catch((e: Error | string) => { + console.error('Display address failed', e); this.toggleConfirmAddr(); - throw new Error(e); }); }} > @@ -192,12 +192,19 @@ class AccountInfo extends React.Component { } } +function isHardwareWallet(wallet: IWallet): wallet is HardwareWallet { + return typeof (wallet as any).displayAddress === 'function'; +} + function mapStateToProps(state: AppState): StateProps { return { balance: state.wallet.balance, network: getNetworkConfig(state), - isOffline: getOffline(state) + isOffline: getOffline(state), + toChecksumAddress: getChecksumAddressFn(state) }; } -const mapDispatchToProps: DispatchProps = { refreshAccountBalance }; +const mapDispatchToProps: DispatchProps = { + refreshAccountBalance: walletActions.refreshAccountBalance +}; export default connect(mapStateToProps, mapDispatchToProps)(AccountInfo); diff --git a/common/components/BalanceSidebar/EquivalentValues.tsx b/common/components/BalanceSidebar/EquivalentValues.tsx index e94ffcbb..bdadcc80 100644 --- a/common/components/BalanceSidebar/EquivalentValues.tsx +++ b/common/components/BalanceSidebar/EquivalentValues.tsx @@ -1,21 +1,23 @@ import React from 'react'; -import translate from 'translations'; -import { UnitDisplay, Spinner } from 'components/ui'; -import Select from 'react-select'; -import { TFetchCCRatesRequested, fetchCCRatesRequested } from 'actions/rates'; -import { rateSymbols } from 'api/rates'; -import { chain, flatMap } from 'lodash'; -import { TokenBalance, getShownTokenBalances } from 'selectors/wallet'; -import { Balance } from 'libs/wallet'; -import './EquivalentValues.scss'; -import { AppState } from 'reducers'; -import { getNetworkConfig, getOffline } from 'selectors/config'; import { connect } from 'react-redux'; +import Select from 'react-select'; +import BN from 'bn.js'; +import { chain, flatMap } from 'lodash'; + +import translate from 'translations'; +import { rateSymbols } from 'api/rates'; +import { NetworkConfig } from 'types/network'; +import { Balance } from 'libs/wallet'; +import { AppState } from 'features/reducers'; +import * as selectors from 'features/selectors'; +import { getOffline, getNetworkConfig } from 'features/config'; +import { ratesActions } from 'features/rates'; +import { walletTypes } from 'features/wallet'; +import { UnitDisplay, Spinner } from 'components/ui'; import btcIco from 'assets/images/bitcoin.png'; import ethIco from 'assets/images/ether.png'; import repIco from 'assets/images/augur.png'; -import { NetworkConfig } from 'types/network'; -import BN from 'bn.js'; +import './EquivalentValues.scss'; interface AllValue { symbol: string; @@ -41,14 +43,14 @@ interface StateProps { balance: Balance; network: NetworkConfig; - tokenBalances: TokenBalance[]; + tokenBalances: walletTypes.TokenBalance[]; rates: AppState['rates']['rates']; ratesError: AppState['rates']['ratesError']; isOffline: AppState['config']['meta']['offline']; } interface DispatchProps { - fetchCCRates: TFetchCCRatesRequested; + fetchCCRates: ratesActions.TFetchCCRatesRequested; } interface FiatSymbols { @@ -79,7 +81,7 @@ class EquivalentValues extends React.Component { public defaultOption( balance: Balance, - tokenBalances: TokenBalance[], + tokenBalances: walletTypes.TokenBalance[], network: StateProps['network'] ): DefaultOption { return { @@ -321,7 +323,7 @@ class EquivalentValues extends React.Component { function mapStateToProps(state: AppState): StateProps { return { balance: state.wallet.balance, - tokenBalances: getShownTokenBalances(state, true), + tokenBalances: selectors.getShownTokenBalances(state, true), network: getNetworkConfig(state), rates: state.rates.rates, ratesError: state.rates.ratesError, @@ -329,4 +331,6 @@ function mapStateToProps(state: AppState): StateProps { }; } -export default connect(mapStateToProps, { fetchCCRates: fetchCCRatesRequested })(EquivalentValues); +export default connect(mapStateToProps, { fetchCCRates: ratesActions.fetchCCRatesRequested })( + EquivalentValues +); diff --git a/common/components/BalanceSidebar/PromoComponents/Coinbase.tsx b/common/components/BalanceSidebar/PromoComponents/Coinbase.tsx index 8dd386c0..9ec0fe79 100644 --- a/common/components/BalanceSidebar/PromoComponents/Coinbase.tsx +++ b/common/components/BalanceSidebar/PromoComponents/Coinbase.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import CoinbaseLogo from 'assets/images/logo-coinbase.svg'; import { NewTabLink } from 'components/ui'; import translate from 'translations'; diff --git a/common/components/BalanceSidebar/PromoComponents/HardwareWallets.tsx b/common/components/BalanceSidebar/PromoComponents/HardwareWallets.tsx index 5348da96..c2d51535 100644 --- a/common/components/BalanceSidebar/PromoComponents/HardwareWallets.tsx +++ b/common/components/BalanceSidebar/PromoComponents/HardwareWallets.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { HELP_ARTICLE } from 'config'; import { HelpLink } from 'components/ui'; import ledgerLogo from 'assets/images/logo-ledger.svg'; diff --git a/common/components/BalanceSidebar/PromoComponents/Shapeshift.tsx b/common/components/BalanceSidebar/PromoComponents/Shapeshift.tsx index ef8343d8..ecfae201 100644 --- a/common/components/BalanceSidebar/PromoComponents/Shapeshift.tsx +++ b/common/components/BalanceSidebar/PromoComponents/Shapeshift.tsx @@ -1,5 +1,6 @@ import React from 'react'; import { Link } from 'react-router-dom'; + import ShapeshiftLogo from 'assets/images/logo-shapeshift.svg'; import translate from 'translations'; diff --git a/common/components/BalanceSidebar/Promos.tsx b/common/components/BalanceSidebar/Promos.tsx index ee4764da..abf4e32e 100644 --- a/common/components/BalanceSidebar/Promos.tsx +++ b/common/components/BalanceSidebar/Promos.tsx @@ -1,9 +1,10 @@ import React from 'react'; import { TransitionGroup, CSSTransition } from 'react-transition-group'; +import { connect } from 'react-redux'; + +import { AppState } from 'features/reducers'; import { HardwareWallets, Coinbase, Shapeshift, Simplex } from './PromoComponents'; import './Promos.scss'; -import { connect } from 'react-redux'; -import { AppState } from '../../reducers'; const CarouselAnimation = ({ children, ...props }: any) => ( diff --git a/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm.tsx b/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm.tsx deleted file mode 100644 index b4b37d29..00000000 --- a/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm.tsx +++ /dev/null @@ -1,166 +0,0 @@ -import React from 'react'; -import { HELP_ARTICLE } from 'config'; -import { isPositiveIntegerOrZero, isValidETHAddress } from 'libs/validators'; -import translate, { translateRaw } from 'translations'; -import { HelpLink, Input } from 'components/ui'; -import './AddCustomTokenForm.scss'; -import { Token } from 'types/network'; - -interface Props { - allTokens: Token[]; - onSave(params: Token): void; - toggleForm(): void; -} - -interface IGenerateSymbolLookup { - [tokenSymbol: string]: boolean; -} - -interface IGenerateAddressLookup { - [address: string]: boolean; -} - -interface State { - tokenSymbolLookup: IGenerateSymbolLookup; - tokenAddressLookup: IGenerateAddressLookup; - address: string; - symbol: string; - decimal: string; -} - -export default class AddCustomTokenForm extends React.PureComponent { - public state: State = { - tokenSymbolLookup: this.generateSymbolLookup(), - tokenAddressLookup: this.generateAddressMap(), - address: '', - symbol: '', - decimal: '' - }; - - public render() { - const { address, symbol, decimal } = this.state; - const errors = this.getErrors(); - - const fields = [ - { - name: 'symbol', - value: symbol, - label: translateRaw('TOKEN_SYMBOL') - }, - { - name: 'address', - value: address, - label: translateRaw('TOKEN_ADDR') - }, - { - name: 'decimal', - value: decimal, - label: translateRaw('TOKEN_DEC') - } - ]; - - return ( -
- {fields.map(field => { - return ( - - ); - })} - - - {translate('ADD_CUSTOM_TKN_HELP')} - -
- - -
-
- ); - } - - public getErrors() { - const { address, symbol, decimal } = this.state; - const errors: { [key: string]: string } = {}; - - // Formatting errors - if (decimal && !isPositiveIntegerOrZero(Number(decimal))) { - errors.decimal = 'Invalid decimal'; - } - if (address) { - if (!isValidETHAddress(address)) { - errors.address = 'Not a valid address'; - } - if (this.state.tokenAddressLookup[address]) { - errors.address = 'A token with this address already exists'; - } - } - - // Message errors - if (symbol && this.state.tokenSymbolLookup[symbol]) { - errors.symbol = 'A token with this symbol already exists'; - } - - return errors; - } - - public isValid() { - const { address, symbol, decimal } = this.state; - return !Object.keys(this.getErrors()).length && address && symbol && decimal; - } - - public onFieldChange = (e: React.FormEvent) => { - // TODO: typescript bug: https://github.com/Microsoft/TypeScript/issues/13948 - const name: any = e.currentTarget.name; - const value = e.currentTarget.value; - this.setState({ [name]: value }); - }; - - public onSave = (ev: React.FormEvent) => { - ev.preventDefault(); - if (!this.isValid()) { - return; - } - - const { address, symbol, decimal } = this.state; - this.props.onSave({ address, symbol, decimal: parseInt(decimal, 10) }); - }; - - private generateSymbolLookup() { - return this.tknArrToMap('symbol'); - } - - private generateAddressMap() { - return this.tknArrToMap('address'); - } - - private tknArrToMap(key: Exclude) { - const tokens = this.props.allTokens; - return tokens.reduce<{ [k: string]: boolean }>((prev, tk) => { - prev[tk[key]] = true; - return prev; - }, {}); - } -} diff --git a/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm.scss b/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/AddCustomTokenForm.scss similarity index 100% rename from common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm.scss rename to common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/AddCustomTokenForm.scss diff --git a/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/AddCustomTokenForm.tsx b/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/AddCustomTokenForm.tsx new file mode 100644 index 00000000..655b1ba0 --- /dev/null +++ b/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/AddCustomTokenForm.tsx @@ -0,0 +1,120 @@ +import React from 'react'; +import { Result } from 'mycrypto-nano-result'; + +import { HELP_ARTICLE } from 'config'; +import translate from 'translations'; +import { Token } from 'types/network'; +import { HelpLink } from 'components/ui'; +import { AddressField } from './AddressField'; +import { DecimalField } from './DecimalField'; +import { SymbolField } from './SymbolField'; +import { BalanceField } from './BalanceField'; +import './AddCustomTokenForm.scss'; + +interface Props { + allTokens: Token[]; + onSave(params: Token): void; + toggleForm(): void; +} + +export interface IGenerateSymbolLookup { + [tokenSymbol: string]: boolean; +} + +export interface IGenerateAddressLookup { + [address: string]: boolean; +} + +interface State { + address: Result; + symbol: Result; + decimal: Result; +} + +export class AddCustomTokenForm extends React.PureComponent { + public state: State = { + address: Result.from({ err: 'This field is empty' }), + symbol: Result.from({ err: 'This field is empty' }), + decimal: Result.from({ err: 'This field is empty' }) + }; + + private tokenSymbolLookup = this.generateSymbolLookup(); + private tokenAddressLookup = this.generateAddressMap(); + + public render() { + const address = this.state.address.toVal().res; + + return ( +
+ + + + + + {translate('ADD_CUSTOM_TKN_HELP')} + +
+ + +
+ + ); + } + + public onSave = (ev: React.FormEvent) => { + ev.preventDefault(); + if (!this.isValid()) { + return; + } + + const { address, symbol, decimal } = this.state; + this.props.onSave({ + address: address.unwrap(), + symbol: symbol.unwrap(), + decimal: parseInt(decimal.unwrap(), 10) + }); + }; + + private handleFieldChange = (fieldName: keyof State) => (res: Result) => { + this.setState({ [fieldName as any]: res }); + }; + + private isValid() { + const { address, decimal, symbol } = this.state; + const valid = address.ok() && decimal.ok() && symbol.ok(); + return valid; + } + + private generateSymbolLookup() { + return this.tokenArrayToMap('symbol'); + } + + private generateAddressMap() { + return this.tokenArrayToMap('address'); + } + + private tokenArrayToMap(key: Exclude) { + const tokens = this.props.allTokens; + return tokens.reduce<{ [k: string]: boolean }>((prev, tk) => { + prev[tk[key]] = true; + return prev; + }, {}); + } +} diff --git a/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/AddressField.tsx b/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/AddressField.tsx new file mode 100644 index 00000000..6ed11eff --- /dev/null +++ b/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/AddressField.tsx @@ -0,0 +1,59 @@ +import React from 'react'; +import { Result } from 'mycrypto-nano-result'; + +import { translateRaw } from 'translations'; +import { isValidETHAddress } from 'libs/validators'; +import { Input } from 'components/ui'; +import { IGenerateAddressLookup } from './AddCustomTokenForm'; + +interface OwnProps { + addressLookup: IGenerateAddressLookup; + onChange(address: Result): void; +} + +enum ErrType { + INVALIDADDR = 'Not a valid address', + ADDRTAKEN = 'A token with this address already exists' +} + +interface State { + address: Result; + userInput: string; +} + +export class AddressField extends React.Component { + public state: State = { + address: Result.from({ res: '' }), + userInput: '' + }; + + public render() { + const { userInput, address } = this.state; + + return ( + + ); + } + + private handleFieldChange = (e: React.FormEvent) => { + const userInput = e.currentTarget.value; + const addrTaken = this.props.addressLookup[userInput]; + const validAddr = isValidETHAddress(userInput); + const err = addrTaken ? ErrType.ADDRTAKEN : !validAddr ? ErrType.INVALIDADDR : undefined; + const address: Result = err ? Result.from({ err }) : Result.from({ res: userInput }); + + this.setState({ userInput, address }); + this.props.onChange(address); + }; +} diff --git a/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/BalanceField.tsx b/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/BalanceField.tsx new file mode 100644 index 00000000..427b3522 --- /dev/null +++ b/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/BalanceField.tsx @@ -0,0 +1,124 @@ +import React from 'react'; +import { connect } from 'react-redux'; +import { Result } from 'mycrypto-nano-result'; + +import ERC20 from 'libs/erc20'; +import { shepherdProvider } from 'libs/nodes'; +import { AppState } from 'features/reducers'; +import { walletSelectors } from 'features/wallet'; +import Spinner from 'components/ui/Spinner'; +import { Input } from 'components/ui'; + +interface OwnProps { + address?: string; +} + +interface StateProps { + walletInst: ReturnType; +} + +interface State { + balance: Result; + addressToLoad?: string; + loading: boolean; +} + +type Props = OwnProps & StateProps; + +class BalanceFieldClass extends React.Component { + public static getDerivedStateFromProps( + nextProps: OwnProps, + prevState: State + ): Partial | null { + if (nextProps.address && nextProps.address !== prevState.addressToLoad) { + return { loading: true, addressToLoad: nextProps.address }; + } + return null; + } + + public state: State = { + balance: Result.from({ res: '' }), + loading: false + }; + + private currentRequest: Promise | null; + + public componentDidUpdate() { + if (this.state.addressToLoad && this.state.loading) { + this.attemptToLoadBalance(this.state.addressToLoad); + } + } + + public componentWillUnmount() { + if (this.currentRequest) { + this.currentRequest = null; + } + } + public render() { + const { balance, loading } = this.state; + + return ( + + ); + } + + private attemptToLoadBalance(address: string) { + // process request + this.currentRequest = this.loadBalance(address) + // set state on successful request e.g it was not cancelled + // and then also set our current request to null + .then(({ balance }) => + this.setState({ + balance, + loading: false + }) + ) + .catch(e => { + console.error(e); + // if the component is unmounted, then dont call set state + if (!this.currentRequest) { + return; + } + + // otherwise it was a failed fetch call + this.setState({ loading: false }); + }) + .then(() => (this.currentRequest = null)); + } + + private loadBalance(address: string) { + if (!this.props.walletInst) { + return Promise.reject('No wallet found'); + } + + const owner = this.props.walletInst.getAddressString(); + return shepherdProvider + .sendCallRequest({ data: ERC20.balanceOf.encodeInput({ _owner: owner }), to: address }) + .then(ERC20.balanceOf.decodeOutput) + .then(({ balance }) => { + const result = Result.from({ res: balance }); + return { balance: result }; + }); + } +} + +function mapStateToProps(state: AppState): StateProps { + return { walletInst: walletSelectors.getWalletInst(state) }; +} + +export const BalanceField = connect(mapStateToProps)(BalanceFieldClass); diff --git a/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/DecimalField.tsx b/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/DecimalField.tsx new file mode 100644 index 00000000..9a4a42cf --- /dev/null +++ b/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/DecimalField.tsx @@ -0,0 +1,34 @@ +import React from 'react'; +import { Result } from 'mycrypto-nano-result'; + +import { translateRaw } from 'translations'; +import { isPositiveIntegerOrZero } from 'libs/validators'; +import { FieldInput } from './FieldInput'; + +interface OwnProps { + address?: string; + onChange(decimals: Result): void; +} + +export class DecimalField extends React.Component { + public render() { + return ( + !(req.toVal().res === '0')} + address={this.props.address} + userInputValidator={this.isValidUserInput} + onChange={this.props.onChange} + /> + ); + } + + private isValidUserInput = (userInput: string) => { + const validDecimals = isPositiveIntegerOrZero(Number(userInput)); + const decimals: Result = validDecimals + ? Result.from({ res: userInput }) + : Result.from({ err: 'Invalid decimal' }); + return decimals; + }; +} diff --git a/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/FieldInput.tsx b/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/FieldInput.tsx new file mode 100644 index 00000000..892f09a7 --- /dev/null +++ b/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/FieldInput.tsx @@ -0,0 +1,134 @@ +import React from 'react'; +import { Result } from 'mycrypto-nano-result'; + +import { shepherdProvider } from 'libs/nodes'; +import ERC20 from 'libs/erc20'; +import Spinner from 'components/ui/Spinner'; +import { Input } from 'components/ui'; + +interface OwnProps { + fieldToFetch: keyof Pick; + fieldName: string; + address?: string; + userInputValidator(input: string): Result; + fetchedFieldValidator?(input: any): Result; + shouldEnableAutoField(input: Result): boolean; + onChange(symbol: Result): void; +} + +interface State { + field: Result; + autoField: boolean; + userInput: string; + addressToLoad?: string; + loading: boolean; +} + +export class FieldInput extends React.Component { + public static getDerivedStateFromProps( + nextProps: OwnProps, + prevState: State + ): Partial | null { + if (nextProps.address && nextProps.address !== prevState.addressToLoad) { + return { loading: true, autoField: true, addressToLoad: nextProps.address }; + } + return null; + } + + public state: State = { + userInput: '', + autoField: true, + field: Result.from({ res: '' }), + loading: false + }; + + private currentRequest: Promise | null; + + public componentDidUpdate() { + if (this.state.addressToLoad && this.state.loading) { + this.attemptToLoadField(this.state.addressToLoad); + } + } + + public componentWillUnmount() { + if (this.currentRequest) { + this.currentRequest = null; + } + } + + public render() { + const { userInput, field, autoField, loading } = this.state; + + return ( + + ); + } + + private handleFieldChange = (args: React.FormEvent) => { + const userInput = args.currentTarget.value; + const field = this.props.userInputValidator(userInput); + this.setState({ userInput, field }); + this.props.onChange(field); + }; + + private attemptToLoadField(address: string) { + // process request + this.currentRequest = this.loadField(address) + // set state on successful request e.g it was not cancelled + // and then also set our current request to null + .then(({ [this.props.fieldToFetch]: field }) => + this.setState({ + field, + loading: false, + autoField: this.props.shouldEnableAutoField(field) + }) + ) + .catch(e => { + console.error(e); + // if the component is unmounted, then dont call set state + if (!this.currentRequest) { + return; + } + + // otherwise it was a failed fetch call + this.setState({ autoField: false, loading: false }); + }) + .then(() => (this.currentRequest = null)); + } + + private loadField(address: string) { + const { fieldToFetch } = this.props; + return shepherdProvider + .sendCallRequest({ data: ERC20[fieldToFetch].encodeInput(), to: address }) + .then(ERC20[fieldToFetch].decodeOutput as any) + .then(({ [fieldToFetch]: field }) => { + let result: Result; + if (this.props.fetchedFieldValidator) { + result = this.props.fetchedFieldValidator(field); + } else { + result = Result.from({ res: field }); + } + + // + // + this.props.onChange(result); + return { [fieldToFetch]: result }; + }); + } +} diff --git a/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/SymbolField.tsx b/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/SymbolField.tsx new file mode 100644 index 00000000..b325c9f3 --- /dev/null +++ b/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/SymbolField.tsx @@ -0,0 +1,40 @@ +import React from 'react'; +import { Result } from 'mycrypto-nano-result'; + +import { translateRaw } from 'translations'; +import { IGenerateSymbolLookup } from './AddCustomTokenForm'; +import { FieldInput } from './FieldInput'; + +interface OwnProps { + address?: string; + symbolLookup: IGenerateSymbolLookup; + onChange(symbol: Result): void; +} + +export class SymbolField extends React.Component { + public render() { + return ( + !req.err()} + address={this.props.address} + userInputValidator={this.isValidUserInput} + fetchedFieldValidator={field => + field + ? Result.from({ res: field }) + : Result.from({ err: 'No Symbol found, please input the token symbol manually' }) + } + onChange={this.props.onChange} + /> + ); + } + + private isValidUserInput = (userInput: string) => { + const validSymbol = !this.props.symbolLookup[userInput]; + const symbol: Result = validSymbol + ? Result.from({ res: userInput }) + : Result.from({ err: 'A token with this symbol already exists' }); + return symbol; + }; +} diff --git a/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/index.ts b/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/index.ts new file mode 100644 index 00000000..bd180f65 --- /dev/null +++ b/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm/index.ts @@ -0,0 +1 @@ +export * from './AddCustomTokenForm'; diff --git a/common/components/BalanceSidebar/TokenBalances/Balances.tsx b/common/components/BalanceSidebar/TokenBalances/Balances.tsx index c21f35d1..ac1776de 100644 --- a/common/components/BalanceSidebar/TokenBalances/Balances.tsx +++ b/common/components/BalanceSidebar/TokenBalances/Balances.tsx @@ -1,13 +1,14 @@ import React from 'react'; + import translate from 'translations'; -import { TokenBalance } from 'selectors/wallet'; -import AddCustomTokenForm from './AddCustomTokenForm'; -import TokenRow from './TokenRow'; import { Token } from 'types/network'; +import { walletTypes } from 'features/wallet'; +import { AddCustomTokenForm } from './AddCustomTokenForm'; +import TokenRow from './TokenRow'; interface Props { allTokens: Token[]; - tokenBalances: TokenBalance[]; + tokenBalances: walletTypes.TokenBalance[]; hasSavedWalletTokens: boolean; scanWalletForTokens(): any; setWalletTokens(tokens: string[]): any; @@ -46,7 +47,7 @@ export default class TokenBalances extends React.PureComponent { let bottom; let help; if (tokenBalances.length && !hasSavedWalletTokens && !this.onlyCustomTokens()) { - help = 'Select which tokens you would like to keep track of'; + help = translate('SELECT_WHICH_TOKENS'); bottom = (
+ +
+
+
+ ); + } + + private doContinue = () => { + localStorage.setItem(LS_KEY, 'true'); + this.setState({ isFading: true }); + + setTimeout(() => { + this.setState({ hasAcknowledged: true }); + }, 1000); + }; + + private reject = () => { + window.location.assign('https://mycrypto.com'); + }; +} diff --git a/common/components/ConfirmationModal/ConfirmationModal.tsx b/common/components/ConfirmationModal/ConfirmationModal.tsx index e151bebf..b6be7dfa 100644 --- a/common/components/ConfirmationModal/ConfirmationModal.tsx +++ b/common/components/ConfirmationModal/ConfirmationModal.tsx @@ -1,10 +1,12 @@ -import { Body } from './components'; +import React from 'react'; +import { Omit } from 'react-redux'; + import { ConfirmationModalTemplate, OwnProps as TemplateProps } from 'components/ConfirmationModalTemplate'; -import React from 'react'; -import { Omit } from 'react-redux'; +import { Body } from './components'; + type Props = Omit; export const ConfirmationModal: React.SFC = props => ( diff --git a/common/components/ConfirmationModal/components/Body/Body.tsx b/common/components/ConfirmationModal/components/Body/Body.tsx index 8c4ab0d2..b11394da 100644 --- a/common/components/ConfirmationModal/components/Body/Body.tsx +++ b/common/components/ConfirmationModal/components/Body/Body.tsx @@ -1,13 +1,14 @@ +import React from 'react'; +import { connect } from 'react-redux'; + +import translate from 'translations'; +import { NetworkConfig } from 'types/network'; +import { AppState } from 'features/reducers'; +import { getNetworkConfig } from 'features/config'; import { Addresses } from './components/Addresses'; import { Amounts } from './components/Amounts'; import { Details } from './components/Details'; -import React from 'react'; -import { connect } from 'react-redux'; -import { AppState } from 'reducers'; import './Body.scss'; -import { getNetworkConfig } from 'selectors/config'; -import { NetworkConfig } from 'types/network'; -import translate from 'translations'; interface State { showDetails: boolean; diff --git a/common/components/ConfirmationModal/components/Body/components/Addresses.tsx b/common/components/ConfirmationModal/components/Body/components/Addresses.tsx index f69f821b..27857328 100644 --- a/common/components/ConfirmationModal/components/Body/components/Addresses.tsx +++ b/common/components/ConfirmationModal/components/Body/components/Addresses.tsx @@ -1,28 +1,29 @@ import React, { Component } from 'react'; -import ERC20 from 'libs/erc20'; -import { Identicon } from 'components/ui'; -import arrow from 'assets/images/tail-triangle-down.svg'; -import './Addresses.scss'; -import { ETHAddressExplorer } from 'config'; import { connect } from 'react-redux'; -import { SerializedTransaction } from 'components/renderCbs'; -import { AppState } from 'reducers'; -import { getFrom, getUnit, isEtherTransaction } from 'selectors/transaction'; -import { toChecksumAddress } from 'ethereumjs-util'; + +import { ETHAddressExplorer } from 'config'; import translate from 'translations'; +import ERC20 from 'libs/erc20'; +import { AppState } from 'features/reducers'; +import * as selectors from 'features/selectors'; +import { getChecksumAddressFn } from 'features/config'; +import arrow from 'assets/images/tail-triangle-down.svg'; +import { SerializedTransaction } from 'components/renderCbs'; +import { Identicon } from 'components/ui'; +import './Addresses.scss'; interface StateProps { - from: AppState['transaction']['meta']['from']; - unit: AppState['transaction']['meta']['unit']; + from: ReturnType; + unit: ReturnType; isToken: boolean; + toChecksumAddress: ReturnType; } const size = '3rem'; class AddressesClass extends Component { public render() { - const { from, isToken, unit } = this.props; - + const { from, isToken, unit, toChecksumAddress } = this.props; return ( { @@ -90,9 +91,10 @@ class AddressesClass extends Component { } const mapStateToProps = (state: AppState): StateProps => ({ - from: getFrom(state), - isToken: !isEtherTransaction(state), - unit: getUnit(state) + from: selectors.getFrom(state), + isToken: !selectors.isEtherTransaction(state), + unit: selectors.getUnit(state), + toChecksumAddress: getChecksumAddressFn(state) }); export const Addresses = connect(mapStateToProps)(AddressesClass); diff --git a/common/components/ConfirmationModal/components/Body/components/Amounts.tsx b/common/components/ConfirmationModal/components/Body/components/Amounts.tsx index 0b06da73..d05637a3 100644 --- a/common/components/ConfirmationModal/components/Body/components/Amounts.tsx +++ b/common/components/ConfirmationModal/components/Body/components/Amounts.tsx @@ -1,15 +1,18 @@ import React, { Component } from 'react'; +import { connect } from 'react-redux'; + +import translate from 'translations'; +import { NetworkConfig } from 'types/network'; +import { AppState } from 'features/reducers'; +import * as derivedSelectors from 'features/selectors'; +import { getNetworkConfig } from 'features/config'; +import { transactionSignTypes } from 'features/transaction'; import { UnitDisplay } from 'components/ui'; import './Amounts.scss'; -import { AppState } from 'reducers'; -import { getAllUSDValuesFromSerializedTx, AllUSDValues } from 'selectors/rates'; -import { SerializedTxParams, getParamsFromSerializedTx } from 'selectors/transaction'; -import { connect } from 'react-redux'; -import { getNetworkConfig } from 'selectors/config'; -import { NetworkConfig } from 'types/network'; -import translate from 'translations'; -interface StateProps extends SerializedTxParams, AllUSDValues { +interface StateProps + extends transactionSignTypes.SerializedTxParams, + derivedSelectors.AllUSDValues { network: NetworkConfig; } @@ -107,8 +110,8 @@ class AmountsClass extends Component { } const mapStateToProps = (state: AppState): StateProps => ({ - ...getParamsFromSerializedTx(state), - ...getAllUSDValuesFromSerializedTx(state), + ...derivedSelectors.getParamsFromSerializedTx(state), + ...derivedSelectors.getAllUSDValuesFromSerializedTx(state), network: getNetworkConfig(state) }); diff --git a/common/components/ConfirmationModal/components/Body/components/Details.tsx b/common/components/ConfirmationModal/components/Body/components/Details.tsx index 3760e40e..d83b3c16 100644 --- a/common/components/ConfirmationModal/components/Body/components/Details.tsx +++ b/common/components/ConfirmationModal/components/Body/components/Details.tsx @@ -1,14 +1,15 @@ import React, { Component } from 'react'; -import './Details.scss'; -import { SerializedTransaction } from 'components/renderCbs'; -import { AppState } from 'reducers'; -import { getNodeConfig } from 'selectors/config'; import { connect } from 'react-redux'; -import { NodeConfig } from 'types/node'; -import translate from 'translations'; -import { CodeBlock, Input } from 'components/ui'; import { addHexPrefix } from 'ethereumjs-util'; +import translate, { translateRaw } from 'translations'; +import { NodeConfig } from 'types/node'; +import { CodeBlock, Input } from 'components/ui'; +import { AppState } from 'features/reducers'; +import { getNodeConfig } from 'features/config'; +import { SerializedTransaction } from 'components/renderCbs'; +import './Details.scss'; + interface StateProps { node: NodeConfig; } @@ -19,12 +20,14 @@ class DetailsClass extends Component { return (
diff --git a/common/components/ConfirmationModal/components/Body/components/Node.tsx b/common/components/ConfirmationModal/components/Body/components/Node.tsx index f8941f1e..2dfe85e7 100644 --- a/common/components/ConfirmationModal/components/Body/components/Node.tsx +++ b/common/components/ConfirmationModal/components/Body/components/Node.tsx @@ -1,8 +1,10 @@ import React, { Component } from 'react'; -import { AppState } from 'reducers'; import { connect } from 'react-redux'; -import { getNodeConfig } from 'selectors/config'; + +import translate from 'translations'; import { StaticNodeConfig } from 'types/node'; +import { AppState } from 'features/reducers'; +import { getNodeConfig } from 'features/config'; interface StateProps { node: StaticNodeConfig; @@ -12,8 +14,8 @@ class NodeClass extends Component { public render() { return (
  • - You are interacting with the {this.props.node.network} network provided by{' '} - {this.props.node.service} + {translate('YOU_ARE_INTERACTING')} {this.props.node.network} + {translate('NETWORK')} {translate('PROVIDED_BY')} {this.props.node.service}
  • ); } diff --git a/common/components/ConfirmationModalTemplate/ConfirmationModalTemplate.tsx b/common/components/ConfirmationModalTemplate/ConfirmationModalTemplate.tsx index 78a8c111..f0c87969 100644 --- a/common/components/ConfirmationModalTemplate/ConfirmationModalTemplate.tsx +++ b/common/components/ConfirmationModalTemplate/ConfirmationModalTemplate.tsx @@ -1,28 +1,23 @@ import React from 'react'; +import { connect } from 'react-redux'; + +import { translateRaw, translate } from 'translations'; +import { AppState } from 'features/reducers'; +import { getLanguageSelection } from 'features/config'; +import { transactionBroadcastActions, transactionSelectors } from 'features/transaction'; +import { walletSelectors } from 'features/wallet'; import Modal, { IButton } from 'components/ui/Modal'; import Spinner from 'components/ui/Spinner'; -import { connect } from 'react-redux'; -import { getWalletType, IWalletType } from 'selectors/wallet'; -import { getLanguageSelection } from 'selectors/config'; -import { - broadcastLocalTransactionRequested, - TBroadcastLocalTransactionRequested, - broadcastWeb3TransactionRequested, - TBroadcastWeb3TransactionRequested -} from 'actions/transaction'; -import { currentTransactionBroadcasting } from 'selectors/transaction'; import './ConfirmationModalTemplate.scss'; -import { AppState } from 'reducers'; -import { translateRaw, translate } from 'translations'; interface DispatchProps { - broadcastLocalTransactionRequested: TBroadcastLocalTransactionRequested; - broadcastWeb3TransactionRequested: TBroadcastWeb3TransactionRequested; + broadcastLocalTransactionRequested: transactionBroadcastActions.TBroadcastLocalTransactionRequested; + broadcastWeb3TransactionRequested: transactionBroadcastActions.TBroadcastWeb3TransactionRequested; } interface StateProps { lang: string; - walletTypes: IWalletType; + walletTypes: walletSelectors.IWalletType; transactionBroadcasting: boolean; } @@ -133,9 +128,13 @@ class ConfirmationModalTemplateClass extends React.Component { export const ConfirmationModalTemplate = connect( (state: AppState) => ({ - transactionBroadcasting: currentTransactionBroadcasting(state), + transactionBroadcasting: transactionSelectors.currentTransactionBroadcasting(state), lang: getLanguageSelection(state), - walletTypes: getWalletType(state) + walletTypes: walletSelectors.getWalletType(state) }), - { broadcastLocalTransactionRequested, broadcastWeb3TransactionRequested } + { + broadcastLocalTransactionRequested: + transactionBroadcastActions.broadcastLocalTransactionRequested, + broadcastWeb3TransactionRequested: transactionBroadcastActions.broadcastWeb3TransactionRequested + } )(ConfirmationModalTemplateClass); diff --git a/common/components/CurrentCustomMessage.tsx b/common/components/CurrentCustomMessage.tsx index 9b7b6499..2c6081e2 100644 --- a/common/components/CurrentCustomMessage.tsx +++ b/common/components/CurrentCustomMessage.tsx @@ -1,12 +1,14 @@ import React, { PureComponent } from 'react'; import { connect } from 'react-redux'; -import { AppState } from 'reducers'; -import { getCurrentTo, ICurrentTo } from 'selectors/transaction'; -import { getAllTokens } from 'selectors/config'; -import { getWalletInst } from 'selectors/wallet'; + import { getAddressMessage } from 'config'; -import { Address } from 'components/ui'; import { Token } from 'types/network'; +import { ICurrentTo } from 'features/types'; +import { AppState } from 'features/reducers'; +import * as derivedSelectors from 'features/selectors'; +import { getAllTokens } from 'features/config'; +import { walletSelectors } from 'features/wallet'; +import { Address } from 'components/ui'; interface ReduxProps { currentTo: ICurrentTo; @@ -116,7 +118,7 @@ class CurrentCustomMessageClass extends PureComponent { } export const CurrentCustomMessage = connect((state: AppState): ReduxProps => ({ - currentTo: getCurrentTo(state), + currentTo: derivedSelectors.getCurrentTo(state), tokens: getAllTokens(state), - wallet: getWalletInst(state) + wallet: walletSelectors.getWalletInst(state) }))(CurrentCustomMessageClass); diff --git a/common/components/CustomNodeModal/CustomNodeModal.tsx b/common/components/CustomNodeModal/CustomNodeModal.tsx index 883f8679..f286c9f0 100644 --- a/common/components/CustomNodeModal/CustomNodeModal.tsx +++ b/common/components/CustomNodeModal/CustomNodeModal.tsx @@ -1,17 +1,21 @@ import React from 'react'; -import Modal, { IButton } from 'components/ui/Modal'; +import { connect } from 'react-redux'; +import { exists, SuccessConfig, FailConfig } from 'mycrypto-eth-exists'; + import translate, { translateRaw } from 'translations'; import { CustomNetworkConfig } from 'types/network'; import { CustomNodeConfig } from 'types/node'; -import { TAddCustomNetwork, addCustomNetwork, AddCustomNodeAction } from 'actions/config'; -import { connect } from 'react-redux'; -import { AppState } from 'reducers'; +import { AppState } from 'features/reducers'; import { getCustomNetworkConfigs, + getStaticNetworkConfigs, getCustomNodeConfigs, - getStaticNetworkConfigs -} from 'selectors/config'; + AddCustomNodeAction, + TAddCustomNetwork, + addCustomNetwork +} from 'features/config'; import { Input, Dropdown } from 'components/ui'; +import Modal, { IButton } from 'components/ui/Modal'; import './CustomNodeModal.scss'; const CUSTOM = { label: 'Custom', value: 'custom' }; @@ -42,12 +46,13 @@ interface State { hasAuth: boolean; username: string; password: string; + defaultNodes: ((SuccessConfig | FailConfig) & { display: string; index: number })[]; } type Props = OwnProps & StateProps & DispatchProps; class CustomNodeModal extends React.Component { - public INITIAL_STATE = { + public INITIAL_STATE: State = { name: '', url: '', network: Object.keys(this.props.staticNetworks)[0], @@ -56,10 +61,19 @@ class CustomNodeModal extends React.Component { customNetworkChainId: '', hasAuth: false, username: '', - password: '' + password: '', + defaultNodes: [] }; + public state: State = this.INITIAL_STATE; + private timer: number | null; + + constructor(props: Props) { + super(props); + this.pollForDefaultNodes(); + } + public componentDidUpdate(prevProps: Props) { // Reset state when modal opens if (!prevProps.isOpen && prevProps.isOpen !== this.props.isOpen) { @@ -67,6 +81,13 @@ class CustomNodeModal extends React.Component { } } + public componentWillUnmount() { + if (this.timer) { + window.clearInterval(this.timer); + } + this.timer = null; + } + public render() { const { customNetworks, handleClose, staticNetworks, isOpen } = this.props; const { network, customNetworkChainId } = this.state; @@ -114,6 +135,8 @@ class CustomNodeModal extends React.Component {
    )} + {this.renderDefaultNodeDropdown()} +
    @@ -74,8 +75,10 @@ class NonceField extends React.Component { const mapStateToProps = (state: AppState): StateProps => { return { isOffline: getOffline(state), - noncePending: nonceRequestPending(state) + noncePending: transactionNetworkSelectors.nonceRequestPending(state) }; }; -export default connect(mapStateToProps, { requestNonce: getNonceRequested })(NonceField); +export default connect(mapStateToProps, { + requestNonce: transactionNetworkActions.getNonceRequested +})(NonceField); diff --git a/common/components/NonceFieldFactory/NonceFieldFactory.tsx b/common/components/NonceFieldFactory/NonceFieldFactory.tsx index 2eef88b3..fc8e520c 100644 --- a/common/components/NonceFieldFactory/NonceFieldFactory.tsx +++ b/common/components/NonceFieldFactory/NonceFieldFactory.tsx @@ -1,9 +1,10 @@ -import { NonceInputFactory } from './NonceInputFactory'; -import { inputNonce, TInputNonce } from 'actions/transaction'; import React, { Component } from 'react'; import { connect } from 'react-redux'; -import { AppState } from 'reducers'; + import { sanitizeNumericalInput } from 'libs/values'; +import { AppState } from 'features/reducers'; +import { transactionFieldsActions } from 'features/transaction'; +import { NonceInputFactory } from './NonceInputFactory'; export interface CallbackProps { nonce: AppState['transaction']['fields']['nonce']; @@ -13,7 +14,7 @@ export interface CallbackProps { } interface DispatchProps { - inputNonce: TInputNonce; + inputNonce: transactionFieldsActions.TInputNonce; } interface OwnProps { @@ -34,5 +35,5 @@ class NonceFieldClass extends Component { } export const NonceFieldFactory = connect(null, { - inputNonce + inputNonce: transactionFieldsActions.inputNonce })(NonceFieldClass); diff --git a/common/components/NonceFieldFactory/NonceInputFactory.tsx b/common/components/NonceFieldFactory/NonceInputFactory.tsx index 57349135..b90f8d18 100644 --- a/common/components/NonceFieldFactory/NonceInputFactory.tsx +++ b/common/components/NonceFieldFactory/NonceInputFactory.tsx @@ -1,10 +1,11 @@ import React, { Component } from 'react'; -import { Query } from 'components/renderCbs'; -import { getNonce, nonceRequestFailed } from 'selectors/transaction'; -import { getOffline } from 'selectors/config'; -import { AppState } from 'reducers'; import { connect } from 'react-redux'; + +import { AppState } from 'features/reducers'; +import { getOffline } from 'features/config'; +import { transactionFieldsSelectors, transactionNetworkSelectors } from 'features/transaction'; import { CallbackProps } from 'components/NonceFieldFactory'; +import { Query } from 'components/renderCbs'; interface OwnProps { onChange(ev: React.FormEvent): void; @@ -34,6 +35,6 @@ class NonceInputFactoryClass extends Component { } export const NonceInputFactory = connect((state: AppState) => ({ - shouldDisplay: getOffline(state) || nonceRequestFailed(state), - nonce: getNonce(state) + shouldDisplay: getOffline(state) || transactionNetworkSelectors.nonceRequestFailed(state), + nonce: transactionFieldsSelectors.getNonce(state) }))(NonceInputFactoryClass); diff --git a/common/components/PageNotFound/PageNotFound.tsx b/common/components/PageNotFound/PageNotFound.tsx index 8924b20a..7667aa92 100644 --- a/common/components/PageNotFound/PageNotFound.tsx +++ b/common/components/PageNotFound/PageNotFound.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { Link } from 'react-router-dom'; -import TabSection from '../../containers/TabSection/index'; + +import TabSection from 'containers/TabSection'; import './PageNotFound.scss'; const PageNotFound: React.SFC = () => ( diff --git a/common/components/PageNotFound/index.ts b/common/components/PageNotFound/index.ts index 127f677c..10e6acdd 100644 --- a/common/components/PageNotFound/index.ts +++ b/common/components/PageNotFound/index.ts @@ -1,3 +1 @@ -import PageNotFound from './PageNotFound'; - -export default PageNotFound; +export { default } from './PageNotFound'; diff --git a/common/components/PaperWallet/index.scss b/common/components/PaperWallet/index.scss new file mode 100644 index 00000000..15cf09bf --- /dev/null +++ b/common/components/PaperWallet/index.scss @@ -0,0 +1,89 @@ +// Use px and don't use variables here, we want the wallet to look +// consistent regardless of theme or screen size. + +$wallet-width: 680px; +$wallet-height: 280px; + +.PaperWallet { + position: relative; + margin: 0 auto; + width: $wallet-width; + height: $wallet-height; + border: 1px solid #163151; + user-select: none; + cursor: default; + + &-sidebar { + float: left; + height: 100%; + width: auto; + } + + &-block { + position: relative; + float: left; + width: 27.5%; + padding: 20px; + + &-box { + width: 150px; + height: 150px; + + &.is-shaded { + background: rgba(#000, 0.02); + } + } + + &-text { + position: absolute; + top: 50%; + left: 100%; + width: 100%; + margin: 0; + transform: translate(-50%, -50%) rotate(-90deg); + font-size: 13px; + font-weight: 600; + color: #0b7290; + text-align: center; + text-transform: uppercase; + letter-spacing: 1px; + } + } + + &-info { + float: left; + width: 85%; + padding: 0 20px; + + &-text { + margin: 0 0 5px; + text-align: left; + font-size: 14px; + font-family: 'Roboto Mono', 'Menlo', 'Monaco', 'Consolas', 'Courier New', monospace; + font-weight: 300; + + &-label { + font-weight: 600; + } + } + } + + &-identicon { + position: absolute; + right: 15px; + bottom: 45px; + + &-left { + float: left; + } + + &-text { + float: left; + width: 130px; + padding: 0 5px; + margin: 12px 0 0; + font-size: 9px; + text-align: center; + } + } +} diff --git a/common/components/PaperWallet/index.tsx b/common/components/PaperWallet/index.tsx index db23352f..ea74aecc 100644 --- a/common/components/PaperWallet/index.tsx +++ b/common/components/PaperWallet/index.tsx @@ -1,93 +1,11 @@ -import { Identicon, QRCode } from 'components/ui'; import React from 'react'; +import html2canvas from 'html2canvas'; +import { addHexPrefix, toChecksumAddress } from 'ethereumjs-util'; -import ethLogo from 'assets/images/logo-ethereum-1.png'; import notesBg from 'assets/images/notes-bg.png'; import sidebarImg from 'assets/images/print-sidebar.png'; - -const walletWidth = 680; -const walletHeight = 280; - -const styles: any = { - container: { - position: 'relative', - margin: '0 auto', - width: `${walletWidth}px`, - height: `${walletHeight}px`, - border: '1px solid #163151', - userSelect: 'none', - cursor: 'default' - }, - - // Images - sidebar: { - float: 'left', - height: '100%', - width: 'auto' - }, - ethLogo: { - position: 'absolute', - left: '86px', - height: '100%', - width: 'auto', - zIndex: '-1' - }, - - // Blocks / QR Codes - block: { - position: 'relative', - float: 'left', - width: '27.5%', - padding: '20px' - }, - blockText: { - position: 'absolute', - top: '50%', - left: '100%', - width: '100%', - margin: 0, - transform: 'translate(-50%, -50%) rotate(-90deg)', - fontSize: '13px', - fontWeight: '600', - color: '#0b7290', - textAlign: 'center', - textTransform: 'uppercase', - letterSpacing: '1px' - }, - // Address / private key info - infoContainer: { - float: 'left', - width: '85%', - padding: '0 20px' - }, - infoText: { - margin: '0 0 8px', - textAlign: 'left', - fontSize: '14px', - fontFamily: '"Roboto Mono", Menlo, Monaco, Consolas, "Courier New", monospace', - fontWeight: 300 - }, - infoLabel: { - fontWeight: 600 - }, - identiconContainer: { - position: 'absolute', - right: '15px', - bottom: '45px' - }, - identiconText: { - float: 'left', - width: '130px', - padding: '0 5px', - margin: '12px 0 0', - fontSize: '9px', - textAlign: 'center' - }, - box: { - width: 150, - height: 150 - } -}; +import { Identicon, QRCode } from 'components/ui'; +import './index.scss'; interface Props { address: string; @@ -95,53 +13,65 @@ interface Props { } export default class PaperWallet extends React.Component { + private container: HTMLElement | null; + public render() { - const { privateKey, address } = this.props; + const { privateKey } = this.props; + const address = toChecksumAddress(addHexPrefix(this.props.address)); return ( -
    - MyCrypto Logo - ETH Logo +
    (this.container = el)}> + MyCrypto Logo -
    -
    +
    +
    -

    YOUR ADDRESS

    +

    YOUR ADDRESS

    -
    - -

    AMOUNT / NOTES

    +
    + +

    AMOUNT / NOTES

    -
    -
    +
    +
    -

    YOUR PRIVATE KEY

    +

    YOUR PRIVATE KEY

    -
    -

    - Your Address: +

    +

    + Your Address:
    {address}

    -

    - Your Private Key: +

    + Your Private Key:
    {privateKey}

    -
    -
    +
    +
    -

    Always look for this icon when sending to this wallet

    +

    + Always look for this icon when sending to this wallet +

    ); } + + public toPNG = async () => { + if (!this.container) { + return ''; + } + const canvas = await html2canvas(this.container); + return canvas.toDataURL('image/png'); + }; } diff --git a/common/components/ParityQrSigner.tsx b/common/components/ParityQrSigner.tsx index aca8bf94..5d508a43 100644 --- a/common/components/ParityQrSigner.tsx +++ b/common/components/ParityQrSigner.tsx @@ -1,8 +1,9 @@ import React from 'react'; import classnames from 'classnames'; +import QrSigner from '@parity/qr-signer'; + import translate from 'translations'; import { Spinner } from 'components/ui'; -import QrSigner from '@parity/qr-signer'; import './ParityQrSigner.scss'; interface State { diff --git a/common/components/PrintableWallet/index.tsx b/common/components/PrintableWallet/index.tsx index 3800b5b3..e55dcde0 100644 --- a/common/components/PrintableWallet/index.tsx +++ b/common/components/PrintableWallet/index.tsx @@ -1,53 +1,54 @@ -import { PaperWallet } from 'components'; import React from 'react'; -import printElement from 'utils/printElement'; -import { stripHexPrefix } from 'libs/values'; -import translate, { translateRaw } from 'translations'; -export const print = (address: string, privateKey: string) => () => - address && - privateKey && - printElement(, { - popupFeatures: { - scrollbars: 'no' - }, - styles: ` - * { - box-sizing: border-box; - } - - body { - font-family: Lato, sans-serif; - font-size: 1rem; - line-height: 1.4; - margin: 0; - } - ` - }); +import translate from 'translations'; +import { stripHexPrefix } from 'libs/formatters'; +import { PaperWallet } from 'components'; interface Props { address: string; privateKey: string; } -const PrintableWallet: React.SFC = ({ address, privateKey }) => { - const pkey = stripHexPrefix(privateKey); +interface State { + paperWalletImage: string; +} - return ( - - ); -}; +export default class PrintableWallet extends React.Component { + public state: State = { + paperWalletImage: '' + }; -export default PrintableWallet; + private paperWallet: PaperWallet | null; + + public componentDidMount() { + setTimeout(() => { + if (!this.paperWallet) { + return this.componentDidMount(); + } + + this.paperWallet.toPNG().then(png => this.setState({ paperWalletImage: png })); + }, 500); + } + + public render() { + const { address, privateKey } = this.props; + const { paperWalletImage } = this.state; + const pkey = stripHexPrefix(privateKey); + const disabled = paperWalletImage ? '' : 'disabled'; + + return ( +
    + ); + } +} diff --git a/common/components/SendButton.tsx b/common/components/SendButton.tsx index 4664480e..d17c5e94 100644 --- a/common/components/SendButton.tsx +++ b/common/components/SendButton.tsx @@ -1,8 +1,9 @@ import React from 'react'; -import { SendButtonFactory } from './SendButtonFactory'; + import translate from 'translations'; -import { ConfirmationModal } from 'components/ConfirmationModal'; import { SigningStatus } from 'components'; +import { ConfirmationModal } from 'components/ConfirmationModal'; +import { SendButtonFactory } from './SendButtonFactory'; import './SendButton.scss'; export const SendButton: React.SFC<{ diff --git a/common/components/SendButtonFactory/OfflineBroadcast.tsx b/common/components/SendButtonFactory/OfflineBroadcast.tsx index 1caf46a5..dde98c5b 100644 --- a/common/components/SendButtonFactory/OfflineBroadcast.tsx +++ b/common/components/SendButtonFactory/OfflineBroadcast.tsx @@ -1,8 +1,9 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; import { Link } from 'react-router-dom'; -import { AppState } from 'reducers'; -import { getOffline } from 'selectors/config'; + +import { AppState } from 'features/reducers'; +import { getOffline } from 'features/config'; import { NewTabLink } from 'components/ui'; interface StateProps { diff --git a/common/components/SendButtonFactory/OnlineSend.tsx b/common/components/SendButtonFactory/OnlineSend.tsx index 124ad123..a9a9d482 100644 --- a/common/components/SendButtonFactory/OnlineSend.tsx +++ b/common/components/SendButtonFactory/OnlineSend.tsx @@ -1,22 +1,21 @@ import React, { Component } from 'react'; -import { getOffline } from 'selectors/config'; -import { AppState } from 'reducers'; import { connect } from 'react-redux'; + +import { AppState } from 'features/reducers'; +import * as derivedSelectors from 'features/selectors'; +import { getOffline } from 'features/config'; import { - getCurrentTransactionStatus, - currentTransactionBroadcasted, - signaturePending, - getSignedTx, - getWeb3Tx -} from 'selectors/transaction'; -import { showNotification, TShowNotification } from 'actions/notifications'; -import { ITransactionStatus } from 'reducers/transaction/broadcast'; -import { TSignTransactionRequested, signTransactionRequested } from 'actions/transaction'; + transactionBroadcastTypes, + transactionSignActions, + transactionSignSelectors, + transactionSelectors +} from 'features/transaction'; +import { notificationsActions } from 'features/notifications'; import { ConfirmationModal } from 'components/ConfirmationModal'; interface StateProps { offline: boolean; - currentTransaction: false | ITransactionStatus | null; + currentTransaction: false | transactionBroadcastTypes.ITransactionStatus | null; transactionBroadcasted: boolean; signaturePending: boolean; signedTx: boolean; @@ -27,9 +26,8 @@ interface State { } interface DispatchProps { - showNotification: TShowNotification; - - signTransactionRequested: TSignTransactionRequested; + showNotification: notificationsActions.TShowNotification; + signTransactionRequested: transactionSignActions.TSignTransactionRequested; } interface OwnProps { @@ -90,10 +88,14 @@ class OnlineSendClass extends Component { export const OnlineSend = connect( (state: AppState) => ({ offline: getOffline(state), - currentTransaction: getCurrentTransactionStatus(state), - transactionBroadcasted: currentTransactionBroadcasted(state), - signaturePending: signaturePending(state).isSignaturePending, - signedTx: !!getSignedTx(state) || !!getWeb3Tx(state) + currentTransaction: transactionSelectors.getCurrentTransactionStatus(state), + transactionBroadcasted: transactionSelectors.currentTransactionBroadcasted(state), + signaturePending: derivedSelectors.signaturePending(state).isSignaturePending, + signedTx: + !!transactionSignSelectors.getSignedTx(state) || !!transactionSignSelectors.getWeb3Tx(state) }), - { showNotification, signTransactionRequested } + { + showNotification: notificationsActions.showNotification, + signTransactionRequested: transactionSignActions.signTransactionRequested + } )(OnlineSendClass); diff --git a/common/components/SendButtonFactory/SendButtonFactory.tsx b/common/components/SendButtonFactory/SendButtonFactory.tsx index 5bed56d6..0f00ad96 100644 --- a/common/components/SendButtonFactory/SendButtonFactory.tsx +++ b/common/components/SendButtonFactory/SendButtonFactory.tsx @@ -1,19 +1,17 @@ -import EthTx from 'ethereumjs-tx'; -import { OnlineSend } from './OnlineSend'; -import { getWalletType, IWalletType } from 'selectors/wallet'; import React, { Component } from 'react'; import { connect } from 'react-redux'; -import { AppState } from 'reducers'; -import { ConfirmationModal } from 'components/ConfirmationModal'; +import EthTx from 'ethereumjs-tx'; + +import { AppState } from 'features/reducers'; +import * as derivedSelectors from 'features/selectors'; +import { walletSelectors } from 'features/wallet'; import { - getSerializedTransaction, - getTransaction, - isNetworkRequestPending, - isValidGasPrice, - isValidGasLimit, - getSignedTx, - getWeb3Tx -} from 'selectors/transaction'; + transactionNetworkSelectors, + transactionSignSelectors, + transactionSelectors +} from 'features/transaction'; +import { ConfirmationModal } from 'components/ConfirmationModal'; +import { OnlineSend } from './OnlineSend'; export interface CallbackProps { disabled: boolean; @@ -22,7 +20,7 @@ export interface CallbackProps { } interface StateProps { - walletType: IWalletType; + walletType: walletSelectors.IWalletType; serializedTransaction: AppState['transaction']['sign']['local']['signedTransaction']; transaction: EthTx; isFullTransaction: boolean; @@ -76,13 +74,14 @@ export class SendButtonFactoryClass extends Component { const mapStateToProps = (state: AppState) => { return { - walletType: getWalletType(state), - serializedTransaction: getSerializedTransaction(state), - ...getTransaction(state), - networkRequestPending: isNetworkRequestPending(state), - validGasPrice: isValidGasPrice(state), - validGasLimit: isValidGasLimit(state), - signedTx: !!getSignedTx(state) || !!getWeb3Tx(state) + walletType: walletSelectors.getWalletType(state), + serializedTransaction: derivedSelectors.getSerializedTransaction(state), + ...derivedSelectors.getTransaction(state), + networkRequestPending: transactionNetworkSelectors.isNetworkRequestPending(state), + validGasPrice: transactionSelectors.isValidGasPrice(state), + validGasLimit: transactionSelectors.isValidGasLimit(state), + signedTx: + !!transactionSignSelectors.getSignedTx(state) || !!transactionSignSelectors.getWeb3Tx(state) }; }; diff --git a/common/components/SendEverything/SendEverything.tsx b/common/components/SendEverything/SendEverything.tsx index e9307556..c3a7dd09 100644 --- a/common/components/SendEverything/SendEverything.tsx +++ b/common/components/SendEverything/SendEverything.tsx @@ -1,12 +1,13 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; + +import translate, { translateRaw } from 'translations'; +import { TokenValue, Wei } from 'libs/units'; +import { AppState } from 'features/reducers'; +import { sendEverythingRequested, TSendEverythingRequested } from 'features/transaction/actions'; +import * as selectors from 'features/selectors'; import { Query } from 'components/renderCbs'; import { Tooltip } from 'components/ui'; -import { TokenValue, Wei } from 'libs/units'; -import translate, { translateRaw } from 'translations'; -import { sendEverythingRequested, TSendEverythingRequested } from 'actions/transaction'; -import { getCurrentBalance } from 'selectors/wallet'; -import { AppState } from 'reducers'; import './SendEverything.scss'; interface DispatchProps { @@ -43,6 +44,6 @@ class SendEverythingClass extends Component { }; } export const SendEverything = connect( - (state: AppState) => ({ currentBalance: getCurrentBalance(state) }), + (state: AppState) => ({ currentBalance: selectors.getCurrentBalance(state) }), { sendEverythingRequested } )(SendEverythingClass); diff --git a/common/components/SigningStatus.tsx b/common/components/SigningStatus.tsx index ff65d57c..a2200124 100644 --- a/common/components/SigningStatus.tsx +++ b/common/components/SigningStatus.tsx @@ -1,10 +1,12 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; -import { AppState } from 'reducers'; -import { signaturePending } from 'selectors/transaction'; + +import { translate } from 'translations'; +import { AppState } from 'features/reducers'; +import * as selectors from 'features/selectors'; import { Spinner } from 'components/ui'; import './SigningStatus.scss'; -import { translate } from 'translations'; + interface StateProps { isSignaturePending: boolean; isHardwareWallet: boolean; @@ -30,6 +32,6 @@ class SigningStatusClass extends Component { } } -export const SigningStatus = connect((state: AppState) => signaturePending(state))( +export const SigningStatus = connect((state: AppState) => selectors.signaturePending(state))( SigningStatusClass ); diff --git a/common/components/SubTabs/index.tsx b/common/components/SubTabs/index.tsx index c9819a0a..7f18d33a 100644 --- a/common/components/SubTabs/index.tsx +++ b/common/components/SubTabs/index.tsx @@ -1,6 +1,7 @@ import React from 'react'; -import Select, { Option } from 'react-select'; import { NavLink, RouteComponentProps } from 'react-router-dom'; +import Select, { Option } from 'react-select'; + import './SubTabs.scss'; export interface Tab { diff --git a/common/components/TXMetaDataPanel/TXMetaDataPanel.tsx b/common/components/TXMetaDataPanel/TXMetaDataPanel.tsx index da1bfff3..f21240ae 100644 --- a/common/components/TXMetaDataPanel/TXMetaDataPanel.tsx +++ b/common/components/TXMetaDataPanel/TXMetaDataPanel.tsx @@ -1,26 +1,21 @@ import React from 'react'; -import BN from 'bn.js'; import { connect } from 'react-redux'; -import { - inputGasPrice, - TInputGasPrice, - inputGasPriceIntent, - TInputGasPriceIntent, - getNonceRequested, - TGetNonceRequested, - resetTransactionRequested, - TResetTransactionRequested -} from 'actions/transaction'; -import { fetchCCRatesRequested, TFetchCCRatesRequested } from 'actions/rates'; -import { getNetworkConfig, getOffline } from 'selectors/config'; -import { AppState } from 'reducers'; -import { Units } from 'libs/units'; -import SimpleGas from './components/SimpleGas'; -import AdvancedGas, { AdvancedOptions } from './components/AdvancedGas'; -import './TXMetaDataPanel.scss'; -import { getGasPrice } from 'selectors/transaction'; -import { NetworkConfig } from 'types/network'; +import BN from 'bn.js'; + import { translateRaw } from 'translations'; +import { NetworkConfig } from 'types/network'; +import { Units } from 'libs/units'; +import { AppState } from 'features/reducers'; +import { getOffline, getNetworkConfig } from 'features/config'; +import { + transactionFieldsActions, + transactionFieldsSelectors, + transactionNetworkActions +} from 'features/transaction'; +import { ratesActions } from 'features/rates'; +import AdvancedGas, { AdvancedOptions } from './components/AdvancedGas'; +import SimpleGas from './components/SimpleGas'; +import './TXMetaDataPanel.scss'; type SliderStates = 'simple' | 'advanced'; @@ -31,11 +26,11 @@ interface StateProps { } interface DispatchProps { - inputGasPrice: TInputGasPrice; - inputGasPriceIntent: TInputGasPriceIntent; - fetchCCRates: TFetchCCRatesRequested; - getNonceRequested: TGetNonceRequested; - resetTransactionRequested: TResetTransactionRequested; + inputGasPrice: transactionFieldsActions.TInputGasPrice; + inputGasPriceIntent: transactionFieldsActions.TInputGasPriceIntent; + fetchCCRates: ratesActions.TFetchCCRatesRequested; + getNonceRequested: transactionNetworkActions.TGetNonceRequested; + resetTransactionRequested: transactionFieldsActions.TResetTransactionRequested; } // Set default props for props that can't be truthy or falsy @@ -68,9 +63,14 @@ class TXMetaDataPanel extends React.Component { sliderState: (this.props as DefaultProps).initialState }; - public componentDidMount() { + public componentWillMount() { if (!this.props.offline) { this.props.resetTransactionRequested(); + } + } + + public componentDidMount() { + if (!this.props.offline) { this.props.fetchCCRates([this.props.network.unit]); this.props.getNonceRequested(); } @@ -143,16 +143,16 @@ class TXMetaDataPanel extends React.Component { function mapStateToProps(state: AppState): StateProps { return { - gasPrice: getGasPrice(state), + gasPrice: transactionFieldsSelectors.getGasPrice(state), offline: getOffline(state), network: getNetworkConfig(state) }; } export default connect(mapStateToProps, { - inputGasPrice, - inputGasPriceIntent, - fetchCCRates: fetchCCRatesRequested, - getNonceRequested, - resetTransactionRequested + inputGasPrice: transactionFieldsActions.inputGasPrice, + inputGasPriceIntent: transactionFieldsActions.inputGasPriceIntent, + fetchCCRates: ratesActions.fetchCCRatesRequested, + getNonceRequested: transactionNetworkActions.getNonceRequested, + resetTransactionRequested: transactionFieldsActions.resetTransactionRequested })(TXMetaDataPanel); diff --git a/common/components/TXMetaDataPanel/components/AdvancedGas.tsx b/common/components/TXMetaDataPanel/components/AdvancedGas.tsx index 7ca48c60..366905b2 100644 --- a/common/components/TXMetaDataPanel/components/AdvancedGas.tsx +++ b/common/components/TXMetaDataPanel/components/AdvancedGas.tsx @@ -1,17 +1,16 @@ import React from 'react'; +import { connect } from 'react-redux'; + +import { EAC_SCHEDULING_CONFIG } from 'libs/scheduling'; import { translateRaw } from 'translations'; +import { AppState } from 'features/reducers'; +import { TToggleAutoGasLimit, toggleAutoGasLimit, getAutoGasLimitEnabled } from 'features/config'; +import { scheduleSelectors } from 'features/schedule'; +import { transactionFieldsActions, transactionSelectors } from 'features/transaction'; +import { NonceField, GasLimitField, DataField } from 'components'; +import { Input } from 'components/ui'; import FeeSummary, { RenderData } from './FeeSummary'; import './AdvancedGas.scss'; -import { TToggleAutoGasLimit, toggleAutoGasLimit } from 'actions/config'; -import { AppState } from 'reducers'; -import { TInputGasPrice } from 'actions/transaction'; -import { NonceField, GasLimitField, DataField } from 'components'; -import { connect } from 'react-redux'; -import { getAutoGasLimitEnabled } from 'selectors/config'; -import { isValidGasPrice } from 'selectors/transaction'; -import { Input } from 'components/ui'; -import { EAC_SCHEDULING_CONFIG } from 'libs/scheduling'; -import { getScheduleGasPrice, getTimeBounty } from 'selectors/schedule'; export interface AdvancedOptions { gasPriceField?: boolean; @@ -22,7 +21,7 @@ export interface AdvancedOptions { } interface OwnProps { - inputGasPrice: TInputGasPrice; + inputGasPrice: transactionFieldsActions.TInputGasPrice; gasPrice: AppState['transaction']['fields']['gasPrice']; options?: AdvancedOptions; scheduling?: boolean; @@ -185,9 +184,9 @@ class AdvancedGas extends React.Component { export default connect( (state: AppState) => ({ autoGasLimitEnabled: getAutoGasLimitEnabled(state), - scheduleGasPrice: getScheduleGasPrice(state), - timeBounty: getTimeBounty(state), - validGasPrice: isValidGasPrice(state) + scheduleGasPrice: scheduleSelectors.getScheduleGasPrice(state), + timeBounty: scheduleSelectors.getTimeBounty(state), + validGasPrice: transactionSelectors.isValidGasPrice(state) }), { toggleAutoGasLimit } )(AdvancedGas); diff --git a/common/components/TXMetaDataPanel/components/FeeSummary.tsx b/common/components/TXMetaDataPanel/components/FeeSummary.tsx index 5165af52..5005ce34 100644 --- a/common/components/TXMetaDataPanel/components/FeeSummary.tsx +++ b/common/components/TXMetaDataPanel/components/FeeSummary.tsx @@ -1,16 +1,17 @@ import React from 'react'; -import BN from 'bn.js'; import { connect } from 'react-redux'; -import { AppState } from 'reducers'; +import BN from 'bn.js'; import classNames from 'classnames'; -import { getNetworkConfig, getOffline } from 'selectors/config'; -import { getIsEstimating } from 'selectors/gas'; -import { getGasLimit } from 'selectors/transaction'; -import { UnitDisplay, Spinner } from 'components/ui'; + import { NetworkConfig } from 'types/network'; -import './FeeSummary.scss'; -import { getScheduleGasLimit, getTimeBounty, getSchedulingToggle } from 'selectors/schedule'; import { calcEACTotalCost } from 'libs/scheduling'; +import { AppState } from 'features/reducers'; +import { getOffline, getNetworkConfig } from 'features/config'; +import { gasSelectors } from 'features/gas'; +import { transactionFieldsSelectors } from 'features/transaction'; +import { scheduleSelectors } from 'features/schedule'; +import { UnitDisplay, Spinner } from 'components/ui'; +import './FeeSummary.scss'; export interface RenderData { gasPriceWei: string; @@ -143,14 +144,14 @@ class FeeSummary extends React.Component { function mapStateToProps(state: AppState): ReduxStateProps { return { - gasLimit: getGasLimit(state), + gasLimit: transactionFieldsSelectors.getGasLimit(state), rates: state.rates.rates, network: getNetworkConfig(state), isOffline: getOffline(state), - isGasEstimating: getIsEstimating(state), - scheduling: getSchedulingToggle(state).value, - scheduleGasLimit: getScheduleGasLimit(state), - timeBounty: getTimeBounty(state) + isGasEstimating: gasSelectors.getIsEstimating(state), + scheduling: scheduleSelectors.getSchedulingToggle(state).value, + scheduleGasLimit: scheduleSelectors.getScheduleGasLimit(state), + timeBounty: scheduleSelectors.getTimeBounty(state) }; } diff --git a/common/components/TXMetaDataPanel/components/SimpleGas.tsx b/common/components/TXMetaDataPanel/components/SimpleGas.tsx index 84d065d0..02b407ac 100644 --- a/common/components/TXMetaDataPanel/components/SimpleGas.tsx +++ b/common/components/TXMetaDataPanel/components/SimpleGas.tsx @@ -1,29 +1,24 @@ import React from 'react'; -import Slider, { createSliderWithTooltip } from 'rc-slider'; -import translate from 'translations'; -import './SimpleGas.scss'; -import { AppState } from 'reducers'; -import { - getGasLimitEstimationTimedOut, - getGasEstimationPending, - nonceRequestPending -} from 'selectors/transaction'; import { connect } from 'react-redux'; -import { fetchGasEstimates, TFetchGasEstimates } from 'actions/gas'; -import { getIsWeb3Node } from 'selectors/config'; -import { getEstimates, getIsEstimating } from 'selectors/gas'; -import { Wei, fromWei } from 'libs/units'; +import Slider, { createSliderWithTooltip } from 'rc-slider'; + import { gasPriceDefaults } from 'config'; +import translate from 'translations'; +import { Wei, fromWei } from 'libs/units'; +import { AppState } from 'features/reducers'; +import { getIsWeb3Node } from 'features/config'; +import { transactionFieldsActions, transactionNetworkSelectors } from 'features/transaction'; +import { gasActions, gasSelectors } from 'features/gas'; +import { scheduleSelectors } from 'features/schedule'; import { InlineSpinner } from 'components/ui/InlineSpinner'; -import { TInputGasPrice } from 'actions/transaction'; import FeeSummary from './FeeSummary'; -import { getScheduleGasPrice } from 'selectors/schedule'; +import './SimpleGas.scss'; const SliderWithTooltip = createSliderWithTooltip(Slider); interface OwnProps { gasPrice: AppState['transaction']['fields']['gasPrice']; - setGasPrice: TInputGasPrice; + setGasPrice: transactionFieldsActions.TInputGasPrice; inputGasPrice(rawGas: string): void; } @@ -39,7 +34,7 @@ interface StateProps { } interface ActionProps { - fetchGasEstimates: TFetchGasEstimates; + fetchGasEstimates: gasActions.TFetchGasEstimates; } type Props = OwnProps & StateProps & ActionProps; @@ -152,15 +147,15 @@ class SimpleGas extends React.Component { export default connect( (state: AppState): StateProps => ({ - gasEstimates: getEstimates(state), - isGasEstimating: getIsEstimating(state), - noncePending: nonceRequestPending(state), - gasLimitPending: getGasEstimationPending(state), - gasLimitEstimationTimedOut: getGasLimitEstimationTimedOut(state), + gasEstimates: gasSelectors.getEstimates(state), + isGasEstimating: gasSelectors.getIsEstimating(state), + noncePending: transactionNetworkSelectors.nonceRequestPending(state), + gasLimitPending: transactionNetworkSelectors.getGasEstimationPending(state), + gasLimitEstimationTimedOut: transactionNetworkSelectors.getGasLimitEstimationTimedOut(state), isWeb3Node: getIsWeb3Node(state), - scheduleGasPrice: getScheduleGasPrice(state) + scheduleGasPrice: scheduleSelectors.getScheduleGasPrice(state) }), { - fetchGasEstimates + fetchGasEstimates: gasActions.fetchGasEstimates } )(SimpleGas); diff --git a/common/components/TXMetaDataPanel/index.tsx b/common/components/TXMetaDataPanel/index.tsx index eed93731..7f68f3ca 100644 --- a/common/components/TXMetaDataPanel/index.tsx +++ b/common/components/TXMetaDataPanel/index.tsx @@ -1,2 +1 @@ -import TXMetaDataPanel from './TXMetaDataPanel'; -export default TXMetaDataPanel; +export { default } from './TXMetaDataPanel'; diff --git a/common/components/TogglablePassword.tsx b/common/components/TogglablePassword.tsx index 4c2aa657..a5c25eba 100644 --- a/common/components/TogglablePassword.tsx +++ b/common/components/TogglablePassword.tsx @@ -3,8 +3,9 @@ // Pass `isVisible` and `handleToggleVisibility` to control the visibility // yourself, otherwise all visibiility changes are managed in internal state. import React from 'react'; -import './TogglablePassword.scss'; + import { Input, TextArea } from 'components/ui'; +import './TogglablePassword.scss'; interface Props { // Shared props diff --git a/common/components/TransactionStatus/TransactionDataTable.tsx b/common/components/TransactionStatus/TransactionDataTable.tsx index ff9cd069..158b950e 100644 --- a/common/components/TransactionStatus/TransactionDataTable.tsx +++ b/common/components/TransactionStatus/TransactionDataTable.tsx @@ -1,8 +1,9 @@ import React from 'react'; + import translate from 'translations'; -import { Identicon, UnitDisplay, NewTabLink, Address, CodeBlock } from 'components/ui'; import { TransactionData, TransactionReceipt } from 'types/transactions'; import { NetworkConfig } from 'types/network'; +import { Identicon, UnitDisplay, NewTabLink, Address, CodeBlock } from 'components/ui'; import './TransactionDataTable.scss'; interface TableRow { diff --git a/common/components/TransactionStatus/TransactionStatus.tsx b/common/components/TransactionStatus/TransactionStatus.tsx index 13f417a5..247b4c1b 100644 --- a/common/components/TransactionStatus/TransactionStatus.tsx +++ b/common/components/TransactionStatus/TransactionStatus.tsx @@ -1,14 +1,14 @@ import React from 'react'; import { connect } from 'react-redux'; + import translate from 'translations'; -import { fetchTransactionData, TFetchTransactionData } from 'actions/transactions'; -import { getTransactionDatas } from 'selectors/transactions'; -import { getNetworkConfig } from 'selectors/config'; -import { Spinner } from 'components/ui'; -import TransactionDataTable from './TransactionDataTable'; -import { AppState } from 'reducers'; import { NetworkConfig } from 'types/network'; import { TransactionState } from 'types/transactions'; +import { AppState } from 'features/reducers'; +import { getNetworkConfig } from 'features/config'; +import { transactionsActions, transactionsSelectors } from 'features/transactions'; +import { Spinner } from 'components/ui'; +import TransactionDataTable from './TransactionDataTable'; import './TransactionStatus.scss'; interface OwnProps { @@ -21,7 +21,7 @@ interface StateProps { } interface ActionProps { - fetchTransactionData: TFetchTransactionData; + fetchTransactionData: transactionsActions.TFetchTransactionData; } type Props = OwnProps & StateProps & ActionProps; @@ -79,9 +79,11 @@ function mapStateToProps(state: AppState, ownProps: OwnProps): StateProps { const { txHash } = ownProps; return { - tx: getTransactionDatas(state)[txHash], + tx: transactionsSelectors.getTransactionDatas(state)[txHash], network: getNetworkConfig(state) }; } -export default connect(mapStateToProps, { fetchTransactionData })(TransactionStatus); +export default connect(mapStateToProps, { + fetchTransactionData: transactionsActions.fetchTransactionData +})(TransactionStatus); diff --git a/common/components/TransactionStatus/index.tsx b/common/components/TransactionStatus/index.tsx index ae3b19f8..d0d15c43 100644 --- a/common/components/TransactionStatus/index.tsx +++ b/common/components/TransactionStatus/index.tsx @@ -1,2 +1 @@ -import TransactionStatus from './TransactionStatus'; -export default TransactionStatus; +export { default } from './TransactionStatus'; diff --git a/common/components/Translate.tsx b/common/components/Translate.tsx index ca35d3c8..30a72f64 100644 --- a/common/components/Translate.tsx +++ b/common/components/Translate.tsx @@ -1,5 +1,6 @@ import React from 'react'; import Markdown from 'react-markdown'; + import NewTabLink from 'components/ui/NewTabLink'; interface Props { diff --git a/common/components/UnitDropDown/UnitDropDown.tsx b/common/components/UnitDropDown/UnitDropDown.tsx index 0bad9e2e..ef64e621 100644 --- a/common/components/UnitDropDown/UnitDropDown.tsx +++ b/common/components/UnitDropDown/UnitDropDown.tsx @@ -1,22 +1,23 @@ import React, { Component } from 'react'; -import { setUnitMeta, TSetUnitMeta } from 'actions/transaction'; -import { TokenBalance, MergedToken, getShownTokenBalances, getTokens } from 'selectors/wallet'; -import { Query } from 'components/renderCbs'; import { connect } from 'react-redux'; -import { AppState } from 'reducers'; -import { getUnit } from 'selectors/transaction'; -import { getNetworkUnit } from 'selectors/config'; import { Option } from 'react-select'; + +import { AppState } from 'features/reducers'; +import * as selectors from 'features/selectors'; +import { transactionMetaActions } from 'features/transaction'; +import { getNetworkUnit } from 'features/config'; +import { walletTypes } from 'features/wallet'; +import { Query } from 'components/renderCbs'; import { Dropdown } from 'components/ui'; interface DispatchProps { - setUnitMeta: TSetUnitMeta; + setUnitMeta: transactionMetaActions.TSetUnitMeta; } interface StateProps { unit: string; - tokens: TokenBalance[]; - allTokens: MergedToken[]; + tokens: walletTypes.TokenBalance[]; + allTokens: walletTypes.MergedToken[]; showAllTokens?: boolean; networkUnit: string; } @@ -49,15 +50,18 @@ class UnitDropdownClass extends Component { this.props.setUnitMeta(unit.value); }; } -const getTokenSymbols = (tokens: (TokenBalance | MergedToken)[]) => tokens.map(t => t.symbol); +const getTokenSymbols = (tokens: (walletTypes.TokenBalance | walletTypes.MergedToken)[]) => + tokens.map(t => t.symbol); function mapStateToProps(state: AppState) { return { - tokens: getShownTokenBalances(state, true), - allTokens: getTokens(state), - unit: getUnit(state), + tokens: selectors.getShownTokenBalances(state, true), + allTokens: selectors.getTokens(state), + unit: selectors.getUnit(state), networkUnit: getNetworkUnit(state) }; } -export const UnitDropDown = connect(mapStateToProps, { setUnitMeta })(UnitDropdownClass); +export const UnitDropDown = connect(mapStateToProps, { + setUnitMeta: transactionMetaActions.setUnitMeta +})(UnitDropdownClass); diff --git a/common/components/WalletDecrypt/WalletDecrypt.scss b/common/components/WalletDecrypt/WalletDecrypt.scss index 6d9bb4f9..1bf6486d 100644 --- a/common/components/WalletDecrypt/WalletDecrypt.scss +++ b/common/components/WalletDecrypt/WalletDecrypt.scss @@ -103,7 +103,7 @@ $speed: 500ms; max-width: 360px; margin: 0 auto; } - &-label{ + &-label { opacity: 0.8; font-weight: 300; white-space: nowrap; @@ -111,6 +111,17 @@ $speed: 500ms; overflow: hidden; text-overflow: ellipsis; } + + &-override { + position: absolute; + bottom: 0; + right: 0; + opacity: 0.3; + + &:hover { + opacity: 1; + } + } } } diff --git a/common/components/WalletDecrypt/WalletDecrypt.tsx b/common/components/WalletDecrypt/WalletDecrypt.tsx index 041731b0..daa30b1e 100644 --- a/common/components/WalletDecrypt/WalletDecrypt.tsx +++ b/common/components/WalletDecrypt/WalletDecrypt.tsx @@ -1,22 +1,32 @@ import React, { Component } from 'react'; +import { TransitionGroup, CSSTransition } from 'react-transition-group'; +import { withRouter, RouteComponentProps } from 'react-router'; import { connect } from 'react-redux'; import { Link } from 'react-router-dom'; import isEmpty from 'lodash/isEmpty'; -import { TransitionGroup, CSSTransition } from 'react-transition-group'; + import { - setWallet, - TSetWallet, - unlockKeystore, - TUnlockKeystore, - unlockMnemonic, - TUnlockMnemonic, - unlockPrivateKey, - TUnlockPrivateKey, - unlockWeb3, - TUnlockWeb3 -} from 'actions/wallet'; -import { resetTransactionRequested, TResetTransactionRequested } from 'actions/transaction'; + SecureWalletName, + InsecureWalletName, + MiscWalletName, + WalletName, + knowledgeBaseURL, + donationAddressMap +} from 'config'; import translate, { translateRaw } from 'translations'; +import { isWeb3NodeAvailable } from 'libs/nodes/web3'; +import { wikiLink as paritySignerHelpLink } from 'libs/wallet/non-deterministic/parity'; +import { AppState } from 'features/reducers'; +import * as derivedSelectors from 'features/selectors'; +import { walletActions } from 'features/wallet'; +import { transactionFieldsActions } from 'features/transaction'; +import { notificationsActions } from 'features/notifications'; +import LedgerIcon from 'assets/images/wallets/ledger.svg'; +import TrezorIcon from 'assets/images/wallets/trezor.svg'; +import ParitySignerIcon from 'assets/images/wallets/parity-signer.svg'; +import { Errorable } from 'components'; +import { DisabledWallets } from './disables'; +import { getWeb3ProviderInfo } from 'utils/web3'; import { KeystoreDecrypt, LedgerNanoSDecrypt, @@ -30,27 +40,7 @@ import { ParitySignerDecrypt, InsecureWalletWarning } from './components'; -import { AppState } from 'reducers'; -import { showNotification, TShowNotification } from 'actions/notifications'; -import { getDisabledWallets } from 'selectors/wallet'; -import { DisabledWallets } from './disables'; -import { - SecureWalletName, - InsecureWalletName, - MiscWalletName, - WalletName, - knowledgeBaseURL, - donationAddressMap -} from 'config'; -import { isWeb3NodeAvailable } from 'libs/nodes/web3'; -import { getWeb3ProviderInfo } from 'utils/web3'; -import LedgerIcon from 'assets/images/wallets/ledger.svg'; -import TrezorIcon from 'assets/images/wallets/trezor.svg'; -import ParitySignerIcon from 'assets/images/wallets/parity-signer.svg'; -import { wikiLink as paritySignerHelpLink } from 'libs/wallet/non-deterministic/parity'; import './WalletDecrypt.scss'; -import { withRouter, RouteComponentProps } from 'react-router'; -import { Errorable } from 'components'; interface OwnProps { hidden?: boolean; @@ -59,13 +49,13 @@ interface OwnProps { } interface DispatchProps { - unlockKeystore: TUnlockKeystore; - unlockMnemonic: TUnlockMnemonic; - unlockPrivateKey: TUnlockPrivateKey; - unlockWeb3: TUnlockWeb3; - setWallet: TSetWallet; - resetTransactionRequested: TResetTransactionRequested; - showNotification: TShowNotification; + unlockKeystore: walletActions.TUnlockKeystore; + unlockMnemonic: walletActions.TUnlockMnemonic; + unlockPrivateKey: walletActions.TUnlockPrivateKey; + unlockWeb3: walletActions.TUnlockWeb3; + setWallet: walletActions.TSetWallet; + resetTransactionRequested: transactionFieldsActions.TResetTransactionRequested; + showNotification: notificationsActions.TShowNotification; } interface StateProps { @@ -79,8 +69,8 @@ type Props = OwnProps & StateProps & DispatchProps & RouteComponentProps<{}>; type UnlockParams = {} | PrivateKeyValue; interface State { selectedWalletKey: WalletName | null; + isInsecureOverridden: boolean; value: UnlockParams | null; - hasAcknowledgedInsecure: boolean; } interface BaseWalletInfo { @@ -204,8 +194,8 @@ const WalletDecrypt = withRouter( public state: State = { selectedWalletKey: null, - value: null, - hasAcknowledgedInsecure: false + isInsecureOverridden: false, + value: null }; public UNSAFE_componentWillReceiveProps(nextProps: Props) { @@ -228,20 +218,28 @@ const WalletDecrypt = withRouter( } public getDecryptionComponent() { - const { selectedWalletKey, hasAcknowledgedInsecure } = this.state; + const { selectedWalletKey, isInsecureOverridden } = this.state; const selectedWallet = this.getSelectedWallet(); if (!selectedWalletKey || !selectedWallet) { return null; } - if (INSECURE_WALLETS.includes(selectedWalletKey) && !hasAcknowledgedInsecure) { + const isInsecure = INSECURE_WALLETS.includes(selectedWalletKey); + if (isInsecure && !isInsecureOverridden && !process.env.BUILD_DOWNLOADABLE) { return (
    + {process.env.NODE_ENV !== 'production' && ( + + )}
    ); } @@ -289,10 +287,6 @@ const WalletDecrypt = withRouter( ); } - public handleAcknowledgeInsecure = () => { - this.setState({ hasAcknowledgedInsecure: true }); - }; - public buildWalletOptions() { const { computedDisabledWallets } = this.props; const { reasons } = computedDisabledWallets; @@ -386,8 +380,7 @@ const WalletDecrypt = withRouter( window.setTimeout(() => { this.setState({ selectedWalletKey: walletType, - value: wallet.initialParams, - hasAcknowledgedInsecure: false + value: wallet.initialParams }); }, timeout); }; @@ -395,8 +388,7 @@ const WalletDecrypt = withRouter( public clearWalletChoice = () => { this.setState({ selectedWalletKey: null, - value: null, - hasAcknowledgedInsecure: false + value: null }); }; @@ -448,12 +440,18 @@ const WalletDecrypt = withRouter( private isWalletDisabled = (walletKey: WalletName) => { return this.props.computedDisabledWallets.wallets.indexOf(walletKey) !== -1; }; + + private overrideInsecureWarning = () => { + if (process.env.NODE_ENV !== 'production') { + this.setState({ isInsecureOverridden: true }); + } + }; } ); function mapStateToProps(state: AppState, ownProps: Props) { const { disabledWallets } = ownProps; - let computedDisabledWallets = getDisabledWallets(state); + let computedDisabledWallets = derivedSelectors.getDisabledWallets(state); if (disabledWallets) { computedDisabledWallets = { @@ -473,11 +471,11 @@ function mapStateToProps(state: AppState, ownProps: Props) { } export default connect(mapStateToProps, { - unlockKeystore, - unlockMnemonic, - unlockPrivateKey, - unlockWeb3, - setWallet, - resetTransactionRequested, - showNotification + unlockKeystore: walletActions.unlockKeystore, + unlockMnemonic: walletActions.unlockMnemonic, + unlockPrivateKey: walletActions.unlockPrivateKey, + unlockWeb3: walletActions.unlockWeb3, + setWallet: walletActions.setWallet, + resetTransactionRequested: transactionFieldsActions.resetTransactionRequested, + showNotification: notificationsActions.showNotification })(WalletDecrypt) as React.ComponentClass; diff --git a/common/components/WalletDecrypt/components/DeprecationWarning.tsx b/common/components/WalletDecrypt/components/DeprecationWarning.tsx deleted file mode 100644 index 82eab917..00000000 --- a/common/components/WalletDecrypt/components/DeprecationWarning.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import React from 'react'; -import translate from 'translations'; - -const DeprecationWarning: React.SFC<{}> = () => { - if (process.env.BUILD_DOWNLOADABLE) { - return null; - } - - return
    {translate('INSECURE_WALLET_DEPRECATION')}
    ; -}; - -export default DeprecationWarning; diff --git a/common/components/WalletDecrypt/components/DeterministicWalletsModal.tsx b/common/components/WalletDecrypt/components/DeterministicWalletsModal.tsx index 67b046ce..43c0da2a 100644 --- a/common/components/WalletDecrypt/components/DeterministicWalletsModal.tsx +++ b/common/components/WalletDecrypt/components/DeterministicWalletsModal.tsx @@ -1,23 +1,19 @@ import React from 'react'; -import { connect } from 'react-redux'; import Select, { Option } from 'react-select'; -import { toChecksumAddress } from 'ethereumjs-util'; +import { connect } from 'react-redux'; + import translate, { translateRaw } from 'translations'; -import { - DeterministicWalletData, - getDeterministicWallets, - GetDeterministicWalletsAction, - GetDeterministicWalletsArgs, - setDesiredToken, - SetDesiredTokenAction -} from 'actions/deterministicWallets'; -import Modal, { IButton } from 'components/ui/Modal'; -import { AppState } from 'reducers'; import { isValidPath } from 'libs/validators'; -import { getNetworkConfig } from 'selectors/config'; -import { getTokens } from 'selectors/wallet'; -import { getAddressLabels } from 'selectors/addressBook'; +import { AppState } from 'features/reducers'; +import { getNetworkConfig } from 'features/config'; +import * as selectors from 'features/selectors'; +import { + deterministicWalletsTypes, + deterministicWalletsActions +} from 'features/deterministicWallets'; +import { addressBookSelectors } from 'features/addressBook'; import { UnitDisplay, Input } from 'components/ui'; +import Modal, { IButton } from 'components/ui/Modal'; import './DeterministicWalletsModal.scss'; const WALLETS_PER_PAGE = 5; @@ -32,16 +28,18 @@ interface OwnProps { } interface StateProps { - addressLabels: ReturnType; + addressLabels: ReturnType; wallets: AppState['deterministicWallets']['wallets']; desiredToken: AppState['deterministicWallets']['desiredToken']; network: ReturnType; - tokens: ReturnType; + tokens: ReturnType; } interface DispatchProps { - getDeterministicWallets(args: GetDeterministicWalletsArgs): GetDeterministicWalletsAction; - setDesiredToken(tkn: string | undefined): SetDesiredTokenAction; + getDeterministicWallets( + args: deterministicWalletsTypes.GetDeterministicWalletsArgs + ): deterministicWalletsTypes.GetDeterministicWalletsAction; + setDesiredToken(tkn: string | undefined): deterministicWalletsTypes.SetDesiredTokenAction; onCancel(): void; onConfirmAddress(address: string, addressIndex: number): void; onPathChange(dPath: DPath): void; @@ -201,14 +199,13 @@ class DeterministicWalletsModalClass extends React.PureComponent { private getAddresses(props: Props = this.props) { const { dPath, publicKey, chainCode, seed } = props; - if (dPath && ((publicKey && chainCode) || seed)) { if (isValidPath(dPath.value)) { this.props.getDeterministicWallets({ seed, + dPath: dPath.value, publicKey, chainCode, - dPath: dPath.value, limit: WALLETS_PER_PAGE, offset: WALLETS_PER_PAGE * this.state.page }); @@ -277,10 +274,10 @@ class DeterministicWalletsModalClass extends React.PureComponent { ); } - private renderWalletRow(wallet: DeterministicWalletData) { + private renderWalletRow(wallet: deterministicWalletsTypes.DeterministicWalletData) { const { desiredToken, network, addressLabels } = this.props; const { selectedAddress } = this.state; - const label = addressLabels[toChecksumAddress(wallet.address)]; + const label = addressLabels[wallet.address.toLowerCase()]; const spanClassName = label ? 'DWModal-addresses-table-address-text' : ''; // Get renderable values, but keep 'em short @@ -342,17 +339,17 @@ class DeterministicWalletsModalClass extends React.PureComponent { function mapStateToProps(state: AppState): StateProps { return { - addressLabels: getAddressLabels(state), + addressLabels: addressBookSelectors.getAddressLabels(state), wallets: state.deterministicWallets.wallets, desiredToken: state.deterministicWallets.desiredToken, network: getNetworkConfig(state), - tokens: getTokens(state) + tokens: selectors.getTokens(state) }; } const DeterministicWalletsModal = connect(mapStateToProps, { - getDeterministicWallets, - setDesiredToken + getDeterministicWallets: deterministicWalletsActions.getDeterministicWallets, + setDesiredToken: deterministicWalletsActions.setDesiredToken })(DeterministicWalletsModalClass); export default DeterministicWalletsModal; diff --git a/common/components/WalletDecrypt/components/InsecureWalletWarning.scss b/common/components/WalletDecrypt/components/InsecureWalletWarning.scss index d93742a9..0cb476c1 100644 --- a/common/components/WalletDecrypt/components/InsecureWalletWarning.scss +++ b/common/components/WalletDecrypt/components/InsecureWalletWarning.scss @@ -1,36 +1,48 @@ @import 'common/sass/variables'; +@import 'common/sass/mixins'; .WalletWarning { - max-width: 780px; + max-width: 820px; margin: 0 auto; - text-align: left; + text-align: center; &-title { color: $brand-danger; - margin-top: 0; + margin: 0 0 $space; } &-desc { - margin-bottom: $space; - } - - &-check { - margin-bottom: $space * 2; - } - - &-checkboxes { margin-bottom: $space * 2; } &-buttons { display: flex; + flex-direction: column; flex-wrap: wrap; - margin-bottom: -$space-sm; + justify-content: center; + max-width: 440px; + margin: 0 auto #{-$space}; - .btn { - flex: 1; - min-width: 280px; - margin: 0 $space-sm $space-sm; + &-btn { + width: 100%; + margin: 0 0 $space; + + &.is-cancel { + @include reset-button; + opacity: 0.4; + transition: $transition; + + &:hover { + opacity: 1; + } + + .fa { + position: relative; + top: -1px; + margin-right: $space-xs; + font-size: 11px; + } + } } } } @@ -38,7 +50,7 @@ .AcknowledgeCheckbox { margin-bottom: $space-sm; - &-checkbox[type="checkbox"] { + &-checkbox[type='checkbox'] { display: inline-block; margin-right: $space-sm; margin-top: 0; diff --git a/common/components/WalletDecrypt/components/InsecureWalletWarning.tsx b/common/components/WalletDecrypt/components/InsecureWalletWarning.tsx index d1d32845..f24abef6 100644 --- a/common/components/WalletDecrypt/components/InsecureWalletWarning.tsx +++ b/common/components/WalletDecrypt/components/InsecureWalletWarning.tsx @@ -1,129 +1,43 @@ import React from 'react'; -import { HELP_ARTICLE, DOWNLOAD_MYCRYPTO_LINK } from 'config'; -import './InsecureWalletWarning.scss'; import translate from 'translations'; -import { knowledgeBaseURL } from 'config/data'; +import { NewTabLink } from 'components/ui'; +import './InsecureWalletWarning.scss'; interface Props { walletType: string; - onContinue(): void; onCancel(): void; } -interface State { - hasConfirmedSite: boolean; - hasAcknowledgedDownload: boolean; - hasAcknowledgedWallets: boolean; -} - -interface Checkbox { - name: keyof State; - label: string | React.ReactElement; -} - -export class InsecureWalletWarning extends React.Component { - public state: State = { - hasConfirmedSite: false, - hasAcknowledgedDownload: false, - hasAcknowledgedWallets: false - }; - +export class InsecureWalletWarning extends React.Component { constructor(props: Props) { super(props); - if (process.env.BUILD_DOWNLOADABLE) { - props.onContinue(); - } } public render() { - if (process.env.BUILD_DOWNLOADABLE) { - return null; - } - - const { walletType, onContinue, onCancel } = this.props; - const checkboxes: Checkbox[] = [ - { - name: 'hasAcknowledgedWallets', - label: translate('INSECURE_WALLET_WARNING_1') - }, - { - name: 'hasAcknowledgedDownload', - label: translate('INSECURE_WALLET_WARNING_2') - }, - { - name: 'hasConfirmedSite', - label: translate('INSECURE_WALLET_WARNING_3') - } - ]; - const canContinue = checkboxes.reduce( - (prev, checkbox) => prev && this.state[checkbox.name], - true - ); + const { walletType, onCancel } = this.props; return (
    -

    {translate('INSECURE_WALLET_TYPE_TITLE')}

    +

    + {translate('INSECURE_WALLET_TYPE_TITLE', { $wallet_type: walletType })} +

    {translate('INSECURE_WALLET_TYPE_DESC', { $wallet_type: walletType })}

    -
      -
    • - {translate('INSECURE_WALLET_RECOMMEND_1', { - $metamask_article: knowledgeBaseURL + '/' + HELP_ARTICLE.MIGRATE_TO_METAMASK, - $hardware_wallet_article: - knowledgeBaseURL + '/' + HELP_ARTICLE.HARDWARE_WALLET_RECOMMENDATIONS - })} -
    • -
    • - {translate('INSECURE_WALLET_RECOMMEND_2', { - $download_mycrypto: DOWNLOAD_MYCRYPTO_LINK - })} -
    • -
    • - {translate('INSECURE_WALLET_RECOMMEND_3', { - $secure_your_eth_article: knowledgeBaseURL + '/' + HELP_ARTICLE.SECURING_YOUR_ETH - })} -
    • -
    -

    - {translate('WALLET_WARNING_CHECK', { $wallet_type: walletType })} -

    -
    {checkboxes.map(this.makeCheckbox)}
    - -
    ); } - - private makeCheckbox = (checkbox: Checkbox) => { - return ( - - ); - }; - - private handleCheckboxChange = (ev: React.FormEvent) => { - this.setState({ - [ev.currentTarget.name as any]: !!ev.currentTarget.checked - }); - }; } diff --git a/common/components/WalletDecrypt/components/Keystore.tsx b/common/components/WalletDecrypt/components/Keystore.tsx index 1705f28e..44156d51 100644 --- a/common/components/WalletDecrypt/components/Keystore.tsx +++ b/common/components/WalletDecrypt/components/Keystore.tsx @@ -1,10 +1,10 @@ -import { isKeystorePassRequired } from 'libs/wallet'; import React, { PureComponent } from 'react'; + import translate, { translateRaw } from 'translations'; +import { isKeystorePassRequired } from 'libs/wallet'; +import { notificationsActions } from 'features/notifications'; import Spinner from 'components/ui/Spinner'; -import { TShowNotification } from 'actions/notifications'; import { Input } from 'components/ui'; -import DeprecationWarning from './DeprecationWarning'; export interface KeystoreValue { file: string; @@ -35,7 +35,7 @@ export class KeystoreDecrypt extends PureComponent { isPasswordPending: boolean; onChange(value: KeystoreValue): void; onUnlock(): void; - showNotification(level: string, message: string): TShowNotification; + showNotification(level: string, message: string): notificationsActions.TShowNotification; }; public render() { @@ -45,7 +45,6 @@ export class KeystoreDecrypt extends PureComponent { return ( -
    { chainCode: '', dPath: this.props.dPath || this.props.dPaths[0], error: null, - isLoading: false, - showTip: false - }; - - public showTip = () => { - this.setState({ - showTip: true - }); + isLoading: false }; public UNSAFE_componentWillReceiveProps(nextProps: Props) { @@ -58,14 +49,14 @@ class LedgerNanoSDecryptClass extends PureComponent { public render() { const { network } = this.props; - const { dPath, publicKey, chainCode, error, isLoading, showTip } = this.state; + const { dPath, publicKey, chainCode, error, isLoading } = this.state; const showErr = error ? 'is-showing' : ''; if (!dPath) { return ; } - if (window.location.protocol !== 'https:') { + if (!process.env.BUILD_ELECTRON && window.location.protocol !== 'https:') { return (
    @@ -78,6 +69,15 @@ class LedgerNanoSDecryptClass extends PureComponent { return (
    +
    + {translate('LEDGER_TIP', { + $network: network.unit, + $browserSupportState: process.env.BUILD_ELECTRON + ? translateRaw('DISABLED') + : translateRaw('ENABLED') + })} +
    +
    ); diff --git a/common/containers/TabSection/Notifications.tsx b/common/containers/TabSection/Notifications.tsx index 3de1e5d0..d2040342 100644 --- a/common/containers/TabSection/Notifications.tsx +++ b/common/containers/TabSection/Notifications.tsx @@ -1,14 +1,15 @@ -import { closeNotification, Notification, TCloseNotification } from 'actions/notifications'; import React from 'react'; -import { connect } from 'react-redux'; import { TransitionGroup, CSSTransition } from 'react-transition-group'; +import { connect } from 'react-redux'; + +import { AppState } from 'features/reducers'; +import { notificationsTypes, notificationsActions } from 'features/notifications'; import NotificationRow from './NotificationRow'; import './Notifications.scss'; -import { AppState } from 'reducers'; interface Props { - notifications: Notification[]; - closeNotification: TCloseNotification; + notifications: notificationsTypes.Notification[]; + closeNotification: notificationsActions.TCloseNotification; } export class Notifications extends React.Component { @@ -31,4 +32,6 @@ const mapStateToProps = (state: AppState) => ({ notifications: state.notifications }); -export default connect(mapStateToProps, { closeNotification })(Notifications); +export default connect(mapStateToProps, { + closeNotification: notificationsActions.closeNotification +})(Notifications); diff --git a/common/containers/TabSection/OfflineTab.tsx b/common/containers/TabSection/OfflineTab.tsx index 5bbb604d..17f639ca 100644 --- a/common/containers/TabSection/OfflineTab.tsx +++ b/common/containers/TabSection/OfflineTab.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import './OfflineTab.scss'; const OfflineTab: React.SFC<{}> = () => ( diff --git a/common/containers/TabSection/WebTemplate.tsx b/common/containers/TabSection/WebTemplate.tsx index fd3a768c..057d07e7 100644 --- a/common/containers/TabSection/WebTemplate.tsx +++ b/common/containers/TabSection/WebTemplate.tsx @@ -1,12 +1,13 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; + +import { makeAutoNodeName } from 'libs/nodes'; +import { AppState } from 'features/reducers'; +import { getOffline, getLatestBlock } from 'features/config'; import { Footer, Header } from 'components'; -import { AppState } from 'reducers'; +import { Query } from 'components/renderCbs'; import Notifications from './Notifications'; import OfflineTab from './OfflineTab'; -import { getOffline, getLatestBlock } from 'selectors/config'; -import { Query } from 'components/renderCbs'; -import { makeAutoNodeName } from 'libs/nodes'; import './WebTemplate.scss'; interface StateProps { diff --git a/common/containers/Tabs/BroadcastTx/index.tsx b/common/containers/Tabs/BroadcastTx/index.tsx index f7c27940..ab3d5e10 100644 --- a/common/containers/Tabs/BroadcastTx/index.tsx +++ b/common/containers/Tabs/BroadcastTx/index.tsx @@ -1,30 +1,27 @@ import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import TabSection from 'containers/TabSection'; -import translate from 'translations'; -import { - signLocalTransactionSucceeded, - TSignLocalTransactionSucceeded, - signTransactionFailed, - TSignTransactionFailed -} from 'actions/transaction'; -import { computeIndexingHash, getTransactionFields, makeTransaction } from 'libs/transaction'; -import { QRCode, Input, CodeBlock } from 'components/ui'; -import EthTx from 'ethereumjs-tx'; -import { SendButton } from 'components/SendButton'; -import { toBuffer, bufferToHex } from 'ethereumjs-util'; -import { getSerializedTransaction } from 'selectors/transaction'; -import { AppState } from 'reducers'; -import './index.scss'; import { Switch, Route, RouteComponentProps } from 'react-router'; +import { connect } from 'react-redux'; +import { toBuffer, bufferToHex } from 'ethereumjs-util'; +import EthTx from 'ethereumjs-tx'; + +import translate from 'translations'; +import { computeIndexingHash, getTransactionFields, makeTransaction } from 'libs/transaction'; +import { AppState } from 'features/reducers'; +import * as selectors from 'features/selectors'; +import { transactionSignActions } from 'features/transaction'; +import { QRCode, Input, CodeBlock } from 'components/ui'; +import { SendButton } from 'components/SendButton'; +import './index.scss'; + +import TabSection from 'containers/TabSection'; import { RouteNotFound } from 'components/RouteNotFound'; interface StateProps { stateTransaction: AppState['transaction']['sign']['local']['signedTransaction']; } interface DispatchProps { - signLocalTransactionSucceeded: TSignLocalTransactionSucceeded; - signTransactionFailed: TSignTransactionFailed; + signLocalTransactionSucceeded: transactionSignActions.TSignLocalTransactionSucceeded; + signTransactionFailed: transactionSignActions.TSignTransactionFailed; } interface State { userInput: string; @@ -116,6 +113,9 @@ class BroadcastTx extends Component { } export default connect( - (state: AppState) => ({ stateTransaction: getSerializedTransaction(state) }), - { signLocalTransactionSucceeded, signTransactionFailed } + (state: AppState) => ({ stateTransaction: selectors.getSerializedTransaction(state) }), + { + signLocalTransactionSucceeded: transactionSignActions.signLocalTransactionSucceeded, + signTransactionFailed: transactionSignActions.signTransactionFailed + } )(BroadcastTx); diff --git a/common/containers/Tabs/CheckTransaction/components/TxHashInput.tsx b/common/containers/Tabs/CheckTransaction/components/TxHashInput.tsx index 1342c325..0cad1680 100644 --- a/common/containers/Tabs/CheckTransaction/components/TxHashInput.tsx +++ b/common/containers/Tabs/CheckTransaction/components/TxHashInput.tsx @@ -2,10 +2,12 @@ import React from 'react'; import { connect } from 'react-redux'; import Select from 'react-select'; import moment from 'moment'; + import translate from 'translations'; -import { isValidTxHash, isValidETHAddress } from 'libs/validators'; -import { getRecentNetworkTransactions } from 'selectors/transactions'; -import { AppState } from 'reducers'; +import { isValidTxHash } from 'libs/validators'; +import { AppState } from 'features/reducers'; +import * as selectors from 'features/selectors'; +import { getIsValidAddressFn } from 'features/config'; import { Input } from 'components/ui'; import './TxHashInput.scss'; @@ -13,9 +15,12 @@ interface OwnProps { hash?: string; onSubmit(hash: string): void; } + interface ReduxProps { recentTxs: AppState['transactions']['recent']; + isValidAddress: ReturnType; } + type Props = OwnProps & ReduxProps; interface State { @@ -40,7 +45,7 @@ class TxHashInput extends React.Component { } public render() { - const { recentTxs } = this.props; + const { recentTxs, isValidAddress } = this.props; const { hash } = this.state; let selectOptions: Option[] = []; @@ -81,7 +86,7 @@ class TxHashInput extends React.Component { onChange={this.handleChange} /> - {isValidETHAddress(hash) && ( + {isValidAddress(hash) && (

    {translate('SELECT_RECENT_TX_BY_TXHASH')}

    @@ -116,5 +121,6 @@ class TxHashInput extends React.Component { } export default connect((state: AppState): ReduxProps => ({ - recentTxs: getRecentNetworkTransactions(state) + recentTxs: selectors.getRecentNetworkTransactions(state), + isValidAddress: getIsValidAddressFn(state) }))(TxHashInput); diff --git a/common/containers/Tabs/CheckTransaction/index.tsx b/common/containers/Tabs/CheckTransaction/index.tsx index 132db895..528842ee 100644 --- a/common/containers/Tabs/CheckTransaction/index.tsx +++ b/common/containers/Tabs/CheckTransaction/index.tsx @@ -1,16 +1,17 @@ import React from 'react'; -import { connect } from 'react-redux'; import { RouteComponentProps } from 'react-router'; +import { connect } from 'react-redux'; + +import { etherChainExplorerInst } from 'config/data'; +import translate from 'translations'; +import { getParamFromURL } from 'utils/helpers'; +import { NetworkConfig } from 'types/network'; +import { AppState } from 'features/reducers'; +import { getNetworkConfig } from 'features/config'; +import { TransactionStatus as TransactionStatusComponent } from 'components'; import TabSection from 'containers/TabSection'; import TxHashInput from './components/TxHashInput'; -import { TransactionStatus as TransactionStatusComponent } from 'components'; -import { getNetworkConfig } from 'selectors/config'; -import { getParamFromURL } from 'utils/helpers'; -import { AppState } from 'reducers'; -import { NetworkConfig } from 'types/network'; import './index.scss'; -import translate from 'translations'; -import { etherChainExplorerInst } from 'config/data'; interface StateProps { network: NetworkConfig; diff --git a/common/containers/Tabs/Contracts/components/Deploy.tsx b/common/containers/Tabs/Contracts/components/Deploy.tsx index cc7da768..92c9a109 100644 --- a/common/containers/Tabs/Contracts/components/Deploy.tsx +++ b/common/containers/Tabs/Contracts/components/Deploy.tsx @@ -1,20 +1,21 @@ +import React, { Component } from 'react'; +import { connect } from 'react-redux'; + import translate from 'translations'; +import { transactionFieldsActions } from 'features/transaction'; +import { walletActions } from 'features/wallet'; +import { NonceField, TXMetaDataPanel, SigningStatus } from 'components'; +import { FullWalletOnly } from 'components/renderCbs'; +import { TextArea } from 'components/ui'; import { DataFieldFactory } from 'components/DataFieldFactory'; import { SendButtonFactory } from 'components/SendButtonFactory'; import WalletDecrypt, { DISABLE_WALLETS } from 'components/WalletDecrypt'; -import React, { Component } from 'react'; -import { resetTransactionRequested, TResetTransactionRequested } from 'actions/transaction'; -import { resetWallet, TResetWallet } from 'actions/wallet'; -import { connect } from 'react-redux'; -import { FullWalletOnly } from 'components/renderCbs'; -import { NonceField, TXMetaDataPanel, SigningStatus } from 'components'; -import './Deploy.scss'; import { ConfirmationModal } from 'components/ConfirmationModal'; -import { TextArea } from 'components/ui'; +import './Deploy.scss'; interface DispatchProps { - resetWallet: TResetWallet; - resetTransactionRequested: TResetTransactionRequested; + resetWallet: walletActions.TResetWallet; + resetTransactionRequested: transactionFieldsActions.TResetTransactionRequested; } class DeployClass extends Component { @@ -97,6 +98,6 @@ class DeployClass extends Component { } export const Deploy = connect(null, { - resetWallet, - resetTransactionRequested + resetWallet: walletActions.resetWallet, + resetTransactionRequested: transactionFieldsActions.resetTransactionRequested })(DeployClass); diff --git a/common/containers/Tabs/Contracts/components/Interact/components/InteractExplorer/components/AmountField.tsx b/common/containers/Tabs/Contracts/components/Interact/components/InteractExplorer/components/AmountField.tsx index ef437bae..2d9ce6f0 100644 --- a/common/containers/Tabs/Contracts/components/Interact/components/InteractExplorer/components/AmountField.tsx +++ b/common/containers/Tabs/Contracts/components/Interact/components/InteractExplorer/components/AmountField.tsx @@ -1,7 +1,7 @@ -import { AmountFieldFactory } from 'components/AmountFieldFactory'; import React from 'react'; import { Input } from 'components/ui'; +import { AmountFieldFactory } from 'components/AmountFieldFactory'; export const AmountField: React.SFC = () => (
    diff --git a/common/containers/Tabs/Contracts/components/Interact/components/InteractExplorer/components/Fields.tsx b/common/containers/Tabs/Contracts/components/Interact/components/InteractExplorer/components/Fields.tsx index ef28eff8..bb15e369 100644 --- a/common/containers/Tabs/Contracts/components/Interact/components/InteractExplorer/components/Fields.tsx +++ b/common/containers/Tabs/Contracts/components/Interact/components/InteractExplorer/components/Fields.tsx @@ -1,8 +1,9 @@ -import { AmountField } from './AmountField'; import React, { Component } from 'react'; + import { SendButton, TXMetaDataPanel } from 'components'; import WalletDecrypt, { DISABLE_WALLETS } from 'components/WalletDecrypt'; import { FullWalletOnly } from 'components/renderCbs'; +import { AmountField } from './AmountField'; interface OwnProps { button: React.ReactElement; diff --git a/common/containers/Tabs/Contracts/components/Interact/components/InteractExplorer/index.tsx b/common/containers/Tabs/Contracts/components/Interact/components/InteractExplorer/index.tsx index 35e0b73a..084ba5ed 100644 --- a/common/containers/Tabs/Contracts/components/Interact/components/InteractExplorer/index.tsx +++ b/common/containers/Tabs/Contracts/components/Interact/components/InteractExplorer/index.tsx @@ -1,28 +1,24 @@ import React, { Component } from 'react'; -import translate from 'translations'; -import './InteractExplorer.scss'; -import { TShowNotification, showNotification } from 'actions/notifications'; -import { getNodeLib } from 'selectors/config'; -import { getTo, getDataExists } from 'selectors/transaction'; -import { GenerateTransaction } from 'components/GenerateTransaction'; -import { AppState } from 'reducers'; import { connect } from 'react-redux'; -import { Fields } from './components'; -import { - setDataField, - resetTransactionRequested, - TSetDataField, - TResetTransactionRequested, - TSetAsContractInteraction, - TSetAsViewAndSend, - setAsContractInteraction, - setAsViewAndSend -} from 'actions/transaction'; -import { Data } from 'libs/units'; -import { Input, Dropdown } from 'components/ui'; -import { INode } from 'libs/nodes'; import { bufferToHex } from 'ethereumjs-util'; +import translate from 'translations'; +import { Data } from 'libs/units'; +import { INode } from 'libs/nodes'; +import { AppState } from 'features/reducers'; +import { getNodeLib } from 'features/config'; +import { notificationsActions } from 'features/notifications'; +import { + transactionFieldsActions, + transactionFieldsSelectors, + transactionMetaActions, + transactionSelectors +} from 'features/transaction'; +import { GenerateTransaction } from 'components/GenerateTransaction'; +import { Input, Dropdown } from 'components/ui'; +import { Fields } from './components'; +import './InteractExplorer.scss'; + interface StateProps { nodeLib: INode; to: AppState['transaction']['fields']['to']; @@ -30,11 +26,11 @@ interface StateProps { } interface DispatchProps { - showNotification: TShowNotification; - setDataField: TSetDataField; - resetTransactionRequested: TResetTransactionRequested; - setAsContractInteraction: TSetAsContractInteraction; - setAsViewAndSend: TSetAsViewAndSend; + showNotification: notificationsActions.TShowNotification; + setDataField: transactionFieldsActions.TSetDataField; + resetTransactionRequested: transactionFieldsActions.TResetTransactionRequested; + setAsContractInteraction: transactionMetaActions.TSetAsContractInteraction; + setAsViewAndSend: transactionMetaActions.TSetAsViewAndSend; } interface OwnProps { @@ -128,13 +124,20 @@ class InteractExplorerClass extends Component { {selectedFunction && (
    {/* TODO: Use reusable components with validation */} - {selectedFunction.contract.inputs.map(input => { + {selectedFunction.contract.inputs.map((input, index) => { const { type, name } = input; - const inputState = this.state.inputs[name]; + // if name is not supplied to arg, use the index instead + // since that's what the contract ABI function factory subsitutes for the name + // if it is undefined + const parsedName = name === '' ? index : name; + + const inputState = this.state.inputs[parsedName]; return ( -
    +