diff --git a/common/Root.tsx b/common/Root.tsx index 3ae6f5ff..17b07775 100644 --- a/common/Root.tsx +++ b/common/Root.tsx @@ -8,10 +8,8 @@ import GenerateWallet from 'containers/Tabs/GenerateWallet'; import Help from 'containers/Tabs/Help'; import SendTransaction from 'containers/Tabs/SendTransaction'; import Swap from 'containers/Tabs/Swap'; -import ViewWallet from 'containers/Tabs/ViewWallet'; import SignAndVerifyMessage from 'containers/Tabs/SignAndVerifyMessage'; import BroadcastTx from 'containers/Tabs/BroadcastTx'; -import RestoreKeystore from 'containers/Tabs/RestoreKeystore'; import ErrorScreen from 'components/ErrorScreen'; // TODO: fix this @@ -47,13 +45,15 @@ export default class Root extends Component {
- + + + + - @@ -87,7 +87,7 @@ const LegacyRoutes = withRouter(props => { history.push('/ens'); break; case '#view-wallet-info': - history.push('/view-wallet'); + history.push('/account/info'); break; case '#check-tx-status': history.push('/check-tx-status'); @@ -99,6 +99,7 @@ const LegacyRoutes = withRouter(props => { + ); }); diff --git a/common/actions/config/actionCreators.ts b/common/actions/config/actionCreators.ts index dcfea5c4..4a71626c 100644 --- a/common/actions/config/actionCreators.ts +++ b/common/actions/config/actionCreators.ts @@ -25,24 +25,13 @@ export function changeLanguage(sign: string): interfaces.ChangeLanguageAction { } export type TChangeNode = typeof changeNode; -export function changeNode( - nodeSelection: string, - node: NodeConfig -): interfaces.ChangeNodeAction { +export function changeNode(nodeSelection: string, node: NodeConfig): interfaces.ChangeNodeAction { return { type: TypeKeys.CONFIG_NODE_CHANGE, payload: { nodeSelection, node } }; } -export type TChangeGasPrice = typeof changeGasPrice; -export function changeGasPrice(value: number): interfaces.ChangeGasPriceAction { - return { - type: TypeKeys.CONFIG_GAS_PRICE, - payload: value - }; -} - export type TPollOfflineStatus = typeof pollOfflineStatus; export function pollOfflineStatus(): interfaces.PollOfflineStatus { return { @@ -51,9 +40,7 @@ export function pollOfflineStatus(): interfaces.PollOfflineStatus { } export type TChangeNodeIntent = typeof changeNodeIntent; -export function changeNodeIntent( - payload: string -): interfaces.ChangeNodeIntentAction { +export function changeNodeIntent(payload: string): interfaces.ChangeNodeIntentAction { return { type: TypeKeys.CONFIG_NODE_CHANGE_INTENT, payload @@ -61,9 +48,7 @@ export function changeNodeIntent( } export type TAddCustomNode = typeof addCustomNode; -export function addCustomNode( - payload: CustomNodeConfig -): interfaces.AddCustomNodeAction { +export function addCustomNode(payload: CustomNodeConfig): interfaces.AddCustomNodeAction { return { type: TypeKeys.CONFIG_ADD_CUSTOM_NODE, payload @@ -71,9 +56,7 @@ export function addCustomNode( } export type TRemoveCustomNode = typeof removeCustomNode; -export function removeCustomNode( - payload: CustomNodeConfig -): interfaces.RemoveCustomNodeAction { +export function removeCustomNode(payload: CustomNodeConfig): interfaces.RemoveCustomNodeAction { return { type: TypeKeys.CONFIG_REMOVE_CUSTOM_NODE, payload @@ -81,9 +64,7 @@ export function removeCustomNode( } export type TAddCustomNetwork = typeof addCustomNetwork; -export function addCustomNetwork( - payload: CustomNetworkConfig -): interfaces.AddCustomNetworkAction { +export function addCustomNetwork(payload: CustomNetworkConfig): interfaces.AddCustomNetworkAction { return { type: TypeKeys.CONFIG_ADD_CUSTOM_NETWORK, payload @@ -101,9 +82,7 @@ export function removeCustomNetwork( } export type TSetLatestBlock = typeof setLatestBlock; -export function setLatestBlock( - payload: string -): interfaces.SetLatestBlockAction { +export function setLatestBlock(payload: string): interfaces.SetLatestBlockAction { return { type: TypeKeys.CONFIG_SET_LATEST_BLOCK, payload diff --git a/common/actions/config/actionTypes.ts b/common/actions/config/actionTypes.ts index 7e72703d..e42d47eb 100644 --- a/common/actions/config/actionTypes.ts +++ b/common/actions/config/actionTypes.ts @@ -27,12 +27,6 @@ export interface ChangeNodeAction { }; } -/*** Change gas price ***/ -export interface ChangeGasPriceAction { - type: TypeKeys.CONFIG_GAS_PRICE; - payload: number; -} - /*** Poll offline status ***/ export interface PollOfflineStatus { type: TypeKeys.CONFIG_POLL_OFFLINE_STATUS; @@ -83,7 +77,6 @@ export interface Web3UnsetNodeAction { export type ConfigAction = | ChangeNodeAction | ChangeLanguageAction - | ChangeGasPriceAction | ToggleOfflineAction | PollOfflineStatus | ForceOfflineAction diff --git a/common/actions/config/constants.ts b/common/actions/config/constants.ts index 519f2ba6..dff08434 100644 --- a/common/actions/config/constants.ts +++ b/common/actions/config/constants.ts @@ -2,7 +2,6 @@ export enum TypeKeys { CONFIG_LANGUAGE_CHANGE = 'CONFIG_LANGUAGE_CHANGE', CONFIG_NODE_CHANGE = 'CONFIG_NODE_CHANGE', CONFIG_NODE_CHANGE_INTENT = 'CONFIG_NODE_CHANGE_INTENT', - CONFIG_GAS_PRICE = 'CONFIG_GAS_PRICE', CONFIG_TOGGLE_OFFLINE = 'CONFIG_TOGGLE_OFFLINE', CONFIG_FORCE_OFFLINE = 'CONFIG_FORCE_OFFLINE', CONFIG_POLL_OFFLINE_STATUS = 'CONFIG_POLL_OFFLINE_STATUS', diff --git a/common/actions/config/index.ts b/common/actions/config/index.ts index 113dd69a..51fcd517 100644 --- a/common/actions/config/index.ts +++ b/common/actions/config/index.ts @@ -1,2 +1,3 @@ export * from './actionCreators'; export * from './actionTypes'; +export * from './constants'; diff --git a/common/actions/customTokens/index.ts b/common/actions/customTokens/index.ts index 113dd69a..51fcd517 100644 --- a/common/actions/customTokens/index.ts +++ b/common/actions/customTokens/index.ts @@ -1,2 +1,3 @@ export * from './actionCreators'; export * from './actionTypes'; +export * from './constants'; diff --git a/common/actions/transaction/actionCreators/broadcast.ts b/common/actions/transaction/actionCreators/broadcast.ts new file mode 100644 index 00000000..1b50d676 --- /dev/null +++ b/common/actions/transaction/actionCreators/broadcast.ts @@ -0,0 +1,55 @@ +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 new file mode 100644 index 00000000..c9c1f29b --- /dev/null +++ b/common/actions/transaction/actionCreators/current.ts @@ -0,0 +1,16 @@ +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 new file mode 100644 index 00000000..1e0827c3 --- /dev/null +++ b/common/actions/transaction/actionCreators/fields.ts @@ -0,0 +1,93 @@ +import { + SetGasLimitFieldAction, + SetDataFieldAction, + SetToFieldAction, + SetNonceFieldAction, + SetValueFieldAction, + InputGasLimitAction, + InputDataAction, + InputNonceAction, + ResetAction, + 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 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 TReset = typeof reset; +const reset = (): ResetAction => ({ type: TypeKeys.RESET }); + +export { + TInputGasLimit, + TInputNonce, + TInputData, + TSetGasLimitField, + TSetDataField, + TSetToField, + TSetNonceField, + TSetValueField, + TSetGasPriceField, + TReset, + inputGasLimit, + inputNonce, + inputData, + setGasLimitField, + setDataField, + setToField, + setNonceField, + setValueField, + setGasPriceField, + reset +}; diff --git a/common/actions/transaction/actionCreators/index.ts b/common/actions/transaction/actionCreators/index.ts new file mode 100644 index 00000000..32cc4be7 --- /dev/null +++ b/common/actions/transaction/actionCreators/index.ts @@ -0,0 +1,7 @@ +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 new file mode 100644 index 00000000..d27004cb --- /dev/null +++ b/common/actions/transaction/actionCreators/meta.ts @@ -0,0 +1,27 @@ +import { + TypeKeys, + SetUnitMetaAction, + SetTokenValueMetaAction, + SetTokenToMetaAction +} from 'actions/transaction'; + +type TSetTokenBalance = typeof setTokenValue; +type TSetUnitMeta = typeof setUnitMeta; +type TSetTokenTo = typeof setTokenTo; + +const setTokenTo = (payload: SetTokenToMetaAction['payload']): SetTokenToMetaAction => ({ + type: TypeKeys.TOKEN_TO_META_SET, + payload +}); + +const setTokenValue = (payload: SetTokenValueMetaAction['payload']): SetTokenValueMetaAction => ({ + type: TypeKeys.TOKEN_VALUE_META_SET, + payload +}); + +const setUnitMeta = (payload: SetUnitMetaAction['payload']): SetUnitMetaAction => ({ + type: TypeKeys.UNIT_META_SET, + payload +}); + +export { TSetUnitMeta, TSetTokenBalance, TSetTokenTo, setUnitMeta, setTokenValue, setTokenTo }; diff --git a/common/actions/transaction/actionCreators/network.ts b/common/actions/transaction/actionCreators/network.ts new file mode 100644 index 00000000..f6c5fd28 --- /dev/null +++ b/common/actions/transaction/actionCreators/network.ts @@ -0,0 +1,82 @@ +import { + EstimateGasFailedAction, + EstimateGasRequestedAction, + TypeKeys, + 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 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, + estimateGasSucceeded, + getFromRequested, + getFromSucceeded, + getFromFailed, + getNonceRequested, + getNonceFailed, + getNonceSucceeded, + TEstimateGasRequested, + TEstimateGasFailed, + TEstimateGasSucceeded, + TGetFromRequested, + TGetFromSucceeded, + TGetNonceRequested, + TGetNonceSucceeded, + TGetNonceFailed, + TGetFromFailed +}; diff --git a/common/actions/transaction/actionCreators/sendEverything.ts b/common/actions/transaction/actionCreators/sendEverything.ts new file mode 100644 index 00000000..c9a86471 --- /dev/null +++ b/common/actions/transaction/actionCreators/sendEverything.ts @@ -0,0 +1,30 @@ +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 new file mode 100644 index 00000000..4de60e82 --- /dev/null +++ b/common/actions/transaction/actionCreators/sign.ts @@ -0,0 +1,58 @@ +import { + SignTransactionFailedAction, + SignLocalTransactionRequestedAction, + SignWeb3TransactionRequestedAction, + SignLocalTransactionSucceededAction, + SignWeb3TransactionSucceededAction +} from '../actionTypes'; +import { TypeKeys } from '../constants'; + +type TSignTransactionFailed = typeof signTransactionFailed; +const signTransactionFailed = (): SignTransactionFailedAction => ({ + type: TypeKeys.SIGN_TRANSACTION_FAILED +}); + +type TSignLocalTransactionSucceeded = typeof signLocalTransactionSucceeded; +const signLocalTransactionSucceeded = ( + payload: SignLocalTransactionSucceededAction['payload'] +): SignLocalTransactionSucceededAction => ({ + type: TypeKeys.SIGN_LOCAL_TRANSACTION_SUCCEEDED, + payload +}); + +type TSignLocalTransactionRequested = typeof signLocalTransactionRequested; +const signLocalTransactionRequested = ( + payload: SignLocalTransactionRequestedAction['payload'] +): SignLocalTransactionRequestedAction => ({ + type: TypeKeys.SIGN_LOCAL_TRANSACTION_REQUESTED, + payload +}); + +type TSignWeb3TransactionSucceeded = typeof signWeb3TransactionSucceeded; +const signWeb3TransactionSucceeded = ( + payload: SignWeb3TransactionSucceededAction['payload'] +): SignWeb3TransactionSucceededAction => ({ + type: TypeKeys.SIGN_WEB3_TRANSACTION_SUCCEEDED, + payload +}); + +type TSignWeb3TransactionRequested = typeof signWeb3TransactionRequested; +const signWeb3TransactionRequested = ( + payload: SignWeb3TransactionRequestedAction['payload'] +): SignWeb3TransactionRequestedAction => ({ + type: TypeKeys.SIGN_WEB3_TRANSACTION_REQUESTED, + payload +}); + +export { + signTransactionFailed, + signLocalTransactionSucceeded, + signLocalTransactionRequested, + signWeb3TransactionSucceeded, + signWeb3TransactionRequested, + TSignLocalTransactionSucceeded, + TSignLocalTransactionRequested, + TSignWeb3TransactionSucceeded, + TSignWeb3TransactionRequested, + TSignTransactionFailed +}; diff --git a/common/actions/transaction/actionCreators/swap.ts b/common/actions/transaction/actionCreators/swap.ts new file mode 100644 index 00000000..be92e192 --- /dev/null +++ b/common/actions/transaction/actionCreators/swap.ts @@ -0,0 +1,33 @@ +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 new file mode 100644 index 00000000..2bc7200b --- /dev/null +++ b/common/actions/transaction/actionTypes/actionTypes.ts @@ -0,0 +1,34 @@ +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 ResetAction { + type: TypeKeys.RESET; +} + +export type TransactionAction = + | InputFieldAction + | BroadcastAction + | FieldAction + | MetaAction + | NetworkAction + | SignAction + | SwapAction + | ResetAction + | CurrentAction + | SendEverythingAction; diff --git a/common/actions/transaction/actionTypes/broadcast.ts b/common/actions/transaction/actionTypes/broadcast.ts new file mode 100644 index 00000000..7cefd93d --- /dev/null +++ b/common/actions/transaction/actionTypes/broadcast.ts @@ -0,0 +1,35 @@ +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 new file mode 100644 index 00000000..643022c6 --- /dev/null +++ b/common/actions/transaction/actionTypes/current.ts @@ -0,0 +1,17 @@ +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 new file mode 100644 index 00000000..0b151b05 --- /dev/null +++ b/common/actions/transaction/actionTypes/fields.ts @@ -0,0 +1,92 @@ +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 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, + 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 new file mode 100644 index 00000000..3eb256de --- /dev/null +++ b/common/actions/transaction/actionTypes/index.ts @@ -0,0 +1 @@ +export * from './actionTypes'; diff --git a/common/actions/transaction/actionTypes/meta.ts b/common/actions/transaction/actionTypes/meta.ts new file mode 100644 index 00000000..3550d79f --- /dev/null +++ b/common/actions/transaction/actionTypes/meta.ts @@ -0,0 +1,28 @@ +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; + }; +} + +type MetaAction = SetUnitMetaAction | SetTokenValueMetaAction | SetTokenToMetaAction; + +export { MetaAction, SetUnitMetaAction, SetTokenToMetaAction, SetTokenValueMetaAction }; diff --git a/common/actions/transaction/actionTypes/network.ts b/common/actions/transaction/actionTypes/network.ts new file mode 100644 index 00000000..eee14f59 --- /dev/null +++ b/common/actions/transaction/actionTypes/network.ts @@ -0,0 +1,57 @@ +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 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 + | GetFromRequestedAction + | GetFromSucceededAction + | GetFromFailedAction + | GetNonceRequestedAction + | GetNonceSucceededAction + | GetNonceFailedAction; + +export { + EstimateGasRequestedAction, + EstimateGasSucceededAction, + EstimateGasFailedAction, + GetFromRequestedAction, + GetFromSucceededAction, + GetFromFailedAction, + GetNonceRequestedAction, + GetNonceSucceededAction, + GetNonceFailedAction, + NetworkAction +}; diff --git a/common/actions/transaction/actionTypes/sendEverything.ts b/common/actions/transaction/actionTypes/sendEverything.ts new file mode 100644 index 00000000..ff4c6bfb --- /dev/null +++ b/common/actions/transaction/actionTypes/sendEverything.ts @@ -0,0 +1,23 @@ +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 new file mode 100644 index 00000000..d9c46c3c --- /dev/null +++ b/common/actions/transaction/actionTypes/sign.ts @@ -0,0 +1,46 @@ +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 SignLocalTransactionRequestedAction { + type: TypeKeys.SIGN_LOCAL_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 SignWeb3TransactionRequestedAction { + type: TypeKeys.SIGN_WEB3_TRANSACTION_REQUESTED; + payload: EthTx; +} +interface SignWeb3TransactionSucceededAction { + type: TypeKeys.SIGN_WEB3_TRANSACTION_SUCCEEDED; + payload: { transaction: Buffer; indexingHash: string; noVerify?: boolean }; +} +interface SignTransactionFailedAction { + type: TypeKeys.SIGN_TRANSACTION_FAILED; +} + +type SignAction = + | SignLocalTransactionRequestedAction + | SignLocalTransactionSucceededAction + | SignWeb3TransactionRequestedAction + | SignWeb3TransactionSucceededAction + | SignTransactionFailedAction; + +export { + SignLocalTransactionRequestedAction, + SignLocalTransactionSucceededAction, + SignWeb3TransactionRequestedAction, + SignWeb3TransactionSucceededAction, + SignTransactionFailedAction, + SignAction +}; diff --git a/common/actions/transaction/actionTypes/swap.ts b/common/actions/transaction/actionTypes/swap.ts new file mode 100644 index 00000000..6e7f338a --- /dev/null +++ b/common/actions/transaction/actionTypes/swap.ts @@ -0,0 +1,40 @@ +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 new file mode 100644 index 00000000..6da04328 --- /dev/null +++ b/common/actions/transaction/constants.ts @@ -0,0 +1,53 @@ +export enum TypeKeys { + ESTIMATE_GAS_REQUESTED = 'ESTIMATE_GAS_REQUESTED', + ESTIMATE_GAS_SUCCEEDED = 'ESTIMATE_GAS_SUCCEEDED', + ESTIMATE_GAS_FAILED = 'ESTIMATE_GAS_FAILED', + + 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_WEB3_TRANSACTION_REQUESTED = 'SIGN_WEB3_TRANSACTION_REQUESTED', + SIGN_WEB3_TRANSACTION_SUCCEEDED = 'SIGN_WEB3_TRANSACTION_SUCCEEDED', + SIGN_LOCAL_TRANSACTION_REQUESTED = 'SIGN_LOCAL_TRANSACTION_REQUESTED', + 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', + 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', + + RESET = 'RESET' +} diff --git a/common/actions/transaction/index.ts b/common/actions/transaction/index.ts new file mode 100644 index 00000000..d5122d97 --- /dev/null +++ b/common/actions/transaction/index.ts @@ -0,0 +1,3 @@ +export * from './actionCreators'; +export * from './constants'; +export * from './actionTypes'; diff --git a/common/actions/wallet/actionCreators.ts b/common/actions/wallet/actionCreators.ts index f69305f3..7435c972 100644 --- a/common/actions/wallet/actionCreators.ts +++ b/common/actions/wallet/actionCreators.ts @@ -1,5 +1,5 @@ import { Wei, TokenValue } from 'libs/units'; -import { IWallet } from 'libs/wallet/IWallet'; +import { IWallet, WalletConfig } from 'libs/wallet'; import * as types from './actionTypes'; import { TypeKeys } from './constants'; export type TUnlockPrivateKey = typeof unlockPrivateKey; @@ -13,9 +13,7 @@ export function unlockPrivateKey( } export type TUnlockKeystore = typeof unlockKeystore; -export function unlockKeystore( - value: types.KeystoreUnlockParams -): types.UnlockKeystoreAction { +export function unlockKeystore(value: types.KeystoreUnlockParams): types.UnlockKeystoreAction { return { type: TypeKeys.WALLET_UNLOCK_KEYSTORE, payload: value @@ -23,9 +21,7 @@ export function unlockKeystore( } export type TUnlockMnemonic = typeof unlockMnemonic; -export function unlockMnemonic( - value: types.MnemonicUnlockParams -): types.UnlockMnemonicAction { +export function unlockMnemonic(value: types.MnemonicUnlockParams): types.UnlockMnemonicAction { return { type: TypeKeys.WALLET_UNLOCK_MNEMONIC, payload: value @@ -54,9 +50,7 @@ export function setBalancePending(): types.SetBalancePendingAction { } export type TSetBalance = typeof setBalanceFullfilled; -export function setBalanceFullfilled( - value: Wei -): types.SetBalanceFullfilledAction { +export function setBalanceFullfilled(value: Wei): types.SetBalanceFullfilledAction { return { type: TypeKeys.WALLET_SET_BALANCE_FULFILLED, payload: value @@ -69,56 +63,44 @@ export function setBalanceRejected(): types.SetBalanceRejectedAction { }; } -export type TSetTokenBalances = typeof setTokenBalances; -export function setTokenBalances(payload: { +export function setTokenBalancesPending(): types.SetTokenBalancesPendingAction { + return { + type: TypeKeys.WALLET_SET_TOKEN_BALANCES_PENDING + }; +} + +export type TSetTokenBalancesFulfilled = typeof setTokenBalancesFulfilled; +export function setTokenBalancesFulfilled(payload: { [key: string]: { balance: TokenValue; error: string | null; }; -}): types.SetTokenBalancesAction { +}): types.SetTokenBalancesFulfilledAction { return { - type: TypeKeys.WALLET_SET_TOKEN_BALANCES, + type: TypeKeys.WALLET_SET_TOKEN_BALANCES_FULFILLED, payload }; } -export type TBroadcastTx = typeof broadcastTx; -export function broadcastTx( - signedTx: string -): types.BroadcastTxRequestedAction { +export function setTokenBalancesRejected(): types.SetTokenBalancesRejectedAction { return { - type: TypeKeys.WALLET_BROADCAST_TX_REQUESTED, - payload: { - signedTx - } + type: TypeKeys.WALLET_SET_TOKEN_BALANCES_REJECTED }; } -export type TBroadcastTxSucceded = typeof broadcastTxSucceded; -export function broadcastTxSucceded( - txHash: string, - signedTx: string -): types.BroadcastTxSuccededAction { +export type TScanWalletForTokens = typeof scanWalletForTokens; +export function scanWalletForTokens(wallet: IWallet): types.ScanWalletForTokensAction { return { - type: TypeKeys.WALLET_BROADCAST_TX_SUCCEEDED, - payload: { - txHash, - signedTx - } + type: TypeKeys.WALLET_SCAN_WALLET_FOR_TOKENS, + payload: wallet }; } -export type TBroadCastTxFailed = typeof broadCastTxFailed; -export function broadCastTxFailed( - signedTx: string, - errorMsg: string -): types.BroadcastTxFailedAction { +export type TSetWalletTokens = typeof setWalletTokens; +export function setWalletTokens(tokens: string[]): types.SetWalletTokensAction { return { - type: TypeKeys.WALLET_BROADCAST_TX_FAILED, - payload: { - signedTx, - error: errorMsg - } + type: TypeKeys.WALLET_SET_WALLET_TOKENS, + payload: tokens }; } @@ -128,3 +110,11 @@ export function resetWallet(): types.ResetWalletAction { type: TypeKeys.WALLET_RESET }; } + +export type TSetWalletConfig = typeof setWalletConfig; +export function setWalletConfig(config: WalletConfig): types.SetWalletConfigAction { + return { + type: TypeKeys.WALLET_SET_CONFIG, + payload: config + }; +} diff --git a/common/actions/wallet/actionTypes.ts b/common/actions/wallet/actionTypes.ts index e11aab99..a0a2d773 100644 --- a/common/actions/wallet/actionTypes.ts +++ b/common/actions/wallet/actionTypes.ts @@ -1,5 +1,5 @@ import { Wei, TokenValue } from 'libs/units'; -import { IWallet } from 'libs/wallet/IWallet'; +import { IWallet, WalletConfig } from 'libs/wallet'; import { TypeKeys } from './constants'; /*** Unlock Private Key ***/ @@ -45,8 +45,12 @@ export interface SetBalanceRejectedAction { } /*** Set Token Balance ***/ -export interface SetTokenBalancesAction { - type: TypeKeys.WALLET_SET_TOKEN_BALANCES; +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; @@ -55,12 +59,18 @@ export interface SetTokenBalancesAction { }; } -/*** Broadcast Tx ***/ -export interface BroadcastTxRequestedAction { - type: TypeKeys.WALLET_BROADCAST_TX_REQUESTED; - payload: { - signedTx: string; - }; +export interface SetTokenBalancesRejectedAction { + type: TypeKeys.WALLET_SET_TOKEN_BALANCES_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 ***/ @@ -82,20 +92,9 @@ export interface UnlockKeystoreAction { payload: KeystoreUnlockParams; } -export interface BroadcastTxSuccededAction { - type: TypeKeys.WALLET_BROADCAST_TX_SUCCEEDED; - payload: { - txHash: string; - signedTx: string; - }; -} - -export interface BroadcastTxFailedAction { - type: TypeKeys.WALLET_BROADCAST_TX_FAILED; - payload: { - signedTx: string; - error: string; - }; +export interface SetWalletConfigAction { + type: TypeKeys.WALLET_SET_CONFIG; + payload: WalletConfig; } /*** Union Type ***/ @@ -106,7 +105,9 @@ export type WalletAction = | SetBalancePendingAction | SetBalanceFullfilledAction | SetBalanceRejectedAction - | SetTokenBalancesAction - | BroadcastTxRequestedAction - | BroadcastTxFailedAction - | BroadcastTxSuccededAction; + | SetTokenBalancesPendingAction + | SetTokenBalancesFulfilledAction + | SetTokenBalancesRejectedAction + | ScanWalletForTokensAction + | SetWalletTokensAction + | SetWalletConfigAction; diff --git a/common/actions/wallet/constants.ts b/common/actions/wallet/constants.ts index 8ccb8e5d..cf213d28 100644 --- a/common/actions/wallet/constants.ts +++ b/common/actions/wallet/constants.ts @@ -7,9 +7,11 @@ export enum TypeKeys { 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 = 'WALLET_SET_TOKEN_BALANCES', - WALLET_BROADCAST_TX_REQUESTED = 'WALLET_BROADCAST_TX_REQUESTED', - WALLET_BROADCAST_TX_FAILED = 'WALLET_BROADCAST_TX_FAILED', - WALLET_BROADCAST_TX_SUCCEEDED = 'WALLET_BROADCAST_TX_SUCCEEDED', + 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_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' } diff --git a/common/components/AddressField/AddressField.tsx b/common/components/AddressField/AddressField.tsx new file mode 100644 index 00000000..87e098a4 --- /dev/null +++ b/common/components/AddressField/AddressField.tsx @@ -0,0 +1,43 @@ +import { Query } from 'components/renderCbs'; +import { setCurrentTo, TSetCurrentTo } from 'actions/transaction'; +import { AddressInput } from './AddressInput'; +import React from 'react'; +import { connect } from 'react-redux'; + +interface DispatchProps { + setCurrentTo: TSetCurrentTo; +} + +interface OwnProps { + to: string | null; +} + +type Props = DispatchProps & DispatchProps & OwnProps; + +//TODO: add ens resolving +class AddressFieldClass extends React.Component { + public componentDidMount() { + // this 'to' parameter can be either token or actual field related + const { to } = this.props; + if (to) { + this.props.setCurrentTo(to); + } + } + + public render() { + return ; + } + + private setAddress = (ev: React.FormEvent) => { + const { value } = ev.currentTarget; + this.props.setCurrentTo(value); + }; +} + +const AddressField = connect(null, { setCurrentTo })(AddressFieldClass); + +const DefaultAddressField: React.SFC<{}> = () => ( + } /> +); + +export { DefaultAddressField as AddressField }; diff --git a/common/components/AddressField/AddressInput.tsx b/common/components/AddressField/AddressInput.tsx new file mode 100644 index 00000000..9d91c1aa --- /dev/null +++ b/common/components/AddressField/AddressInput.tsx @@ -0,0 +1,56 @@ +import React, { Component } from 'react'; +import { Identicon } from 'components/ui'; +import translate from 'translations'; +//import { EnsAddress } from './components'; +import { Query } from 'components/renderCbs'; +import { donationAddressMap } from 'config/data'; +import { ICurrentTo, getCurrentTo, isValidCurrentTo } from 'selectors/transaction'; +import { connect } from 'react-redux'; +import { AppState } from 'reducers'; + +interface StateProps { + currentTo: ICurrentTo; + isValid: boolean; +} +interface OwnProps { + onChange(ev: React.FormEvent): void; +} + +type Props = OwnProps & StateProps; + +//TODO: ENS handling +class AddressInputClass extends Component { + public render() { + const { currentTo, onChange, isValid } = this.props; + const { raw } = currentTo; + return ( +
+
+ + ( + + )} + /> + {/**/} +
+
+ +
+
+ ); + } +} + +export const AddressInput = connect((state: AppState) => ({ + currentTo: getCurrentTo(state), + isValid: isValidCurrentTo(state) +}))(AddressInputClass); diff --git a/common/components/AddressField/components/EnsAddress.tsx b/common/components/AddressField/components/EnsAddress.tsx new file mode 100644 index 00000000..b26084e4 --- /dev/null +++ b/common/components/AddressField/components/EnsAddress.tsx @@ -0,0 +1,36 @@ +import React from 'react'; +/* + + public onChange = (e: React.SyntheticEvent) => { + const newValue = (e.target as HTMLInputElement).value; + const { onChange } = this.props; + if (!onChange) { + return; + } + // FIXME debounce? + if (isValidENSAddress(newValue)) { + this.props.resolveEnsName(newValue); + } + onChange(newValue); + }; +} +function mapStateToProps(state: AppState, props: PublicProps) { + return { + ensAddress: getEnsAddress(state, props.value) + }; +} +export default connect(mapStateToProps, { resolveEnsName })(AddressField); +*/ + +interface EnsAddressProps { + ensAddress: string | null; +} + +export const EnsAddress: React.SFC = ({ ensAddress }) => + (!!ensAddress && ( +

+ ↳ + {ensAddress} +

+ )) || + null; diff --git a/common/components/AddressField/components/index.ts b/common/components/AddressField/components/index.ts new file mode 100644 index 00000000..ee054d13 --- /dev/null +++ b/common/components/AddressField/components/index.ts @@ -0,0 +1 @@ +export * from './EnsAddress'; diff --git a/common/components/AddressField/index.ts b/common/components/AddressField/index.ts new file mode 100644 index 00000000..3164294b --- /dev/null +++ b/common/components/AddressField/index.ts @@ -0,0 +1 @@ +export * from './AddressField'; diff --git a/common/components/AmountField.tsx b/common/components/AmountField.tsx new file mode 100644 index 00000000..aadff3df --- /dev/null +++ b/common/components/AmountField.tsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { AmountFieldFactory } from './AmountFieldFactory'; +import { Aux } from 'components/ui'; +import { UnitDropDown } from 'components'; +import translate, { translateRaw } from 'translations'; + +interface Props { + hasUnitDropdown?: boolean; +} + +export const AmountField: React.SFC = ({ hasUnitDropdown }) => ( + ( + + + +
+ + {hasUnitDropdown && } +
+
+ )} + /> +); diff --git a/common/components/AmountFieldFactory/AmountFieldFactory.tsx b/common/components/AmountFieldFactory/AmountFieldFactory.tsx new file mode 100644 index 00000000..54374e71 --- /dev/null +++ b/common/components/AmountFieldFactory/AmountFieldFactory.tsx @@ -0,0 +1,59 @@ +import React, { Component } from 'react'; +import { Query } from 'components/renderCbs'; +import { setCurrentValue, TSetCurrentValue } from 'actions/transaction'; +import { connect } from 'react-redux'; +import { AmountInput } from './AmountInputFactory'; +import { AppState } from 'reducers'; + +export interface CallbackProps { + isValid: boolean; + readOnly: boolean; + currentValue: + | AppState['transaction']['fields']['value'] + | AppState['transaction']['meta']['tokenValue']; + onChange(ev: React.FormEvent); +} + +interface DispatchProps { + setCurrentValue: TSetCurrentValue; +} + +interface OwnProps { + value: string | null; + withProps(props: CallbackProps): React.ReactElement | null; +} + +type Props = DispatchProps & OwnProps; + +class AmountFieldClass extends Component { + public componentDidMount() { + const { value } = this.props; + if (value) { + this.props.setCurrentValue(value); + } + } + + public render() { + return ; + } + + private setValue = (ev: React.FormEvent) => { + const { value } = ev.currentTarget; + this.props.setCurrentValue(value); + }; +} + +const AmountField = connect(null, { setCurrentValue })(AmountFieldClass); + +interface DefaultAmountFieldProps { + withProps(props: CallbackProps): React.ReactElement | null; +} + +const DefaultAmountField: React.SFC = ({ withProps }) => ( + } + /> +); + +export { DefaultAmountField as AmountFieldFactory }; diff --git a/common/components/AmountFieldFactory/AmountInputFactory.tsx b/common/components/AmountFieldFactory/AmountInputFactory.tsx new file mode 100644 index 00000000..f7bcec2d --- /dev/null +++ b/common/components/AmountFieldFactory/AmountInputFactory.tsx @@ -0,0 +1,43 @@ +import React, { Component } from 'react'; +import { Query } from 'components/renderCbs'; +import { ICurrentValue, getCurrentValue, isValidAmount } from 'selectors/transaction'; +import { AppState } from 'reducers'; +import { connect } from 'react-redux'; +import { CallbackProps } from 'components/AmountFieldFactory'; + +interface OwnProps { + onChange(ev: React.FormEvent); + withProps(props: CallbackProps): React.ReactElement | null; +} + +interface StateProps { + currentValue: ICurrentValue; + validAmount: boolean; +} + +type Props = OwnProps & StateProps; + +class AmountInputClass extends Component { + public render() { + const { currentValue, onChange, withProps, validAmount } = this.props; + + return ( + + withProps({ + currentValue, + isValid: validAmount, + readOnly: !!readOnly, + onChange + }) + } + /> + ); + } +} + +export const AmountInput = connect((state: AppState) => ({ + currentValue: getCurrentValue(state), + validAmount: isValidAmount(state) +}))(AmountInputClass); diff --git a/common/components/AmountFieldFactory/index.tsx b/common/components/AmountFieldFactory/index.tsx new file mode 100644 index 00000000..92425697 --- /dev/null +++ b/common/components/AmountFieldFactory/index.tsx @@ -0,0 +1 @@ +export * from './AmountFieldFactory'; diff --git a/common/components/BalanceSidebar/AccountInfo.tsx b/common/components/BalanceSidebar/AccountInfo.tsx index e3ff4072..074a2188 100644 --- a/common/components/BalanceSidebar/AccountInfo.tsx +++ b/common/components/BalanceSidebar/AccountInfo.tsx @@ -37,8 +37,7 @@ export default class AccountInfo extends React.Component { this.setAddressFromWallet(); } - // TODO: don't use any; - public toggleShowLongBalance = (e: React.SyntheticEvent) => { + public toggleShowLongBalance = (e: React.FormEvent) => { e.preventDefault(); this.setState(state => { return { @@ -79,6 +78,7 @@ export default class AccountInfo extends React.Component { value={balance.wei} unit={'ether'} displayShortBalance={!showLongBalance} + checkOffline={true} /> )} diff --git a/common/components/BalanceSidebar/EquivalentValues.tsx b/common/components/BalanceSidebar/EquivalentValues.tsx index 6e7e8c1b..4f159c21 100644 --- a/common/components/BalanceSidebar/EquivalentValues.tsx +++ b/common/components/BalanceSidebar/EquivalentValues.tsx @@ -70,7 +70,12 @@ export default class EquivalentValues extends React.Component {
  • {key}:{' '} - +
  • ); diff --git a/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm.scss b/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm.scss new file mode 100644 index 00000000..d1da9de9 --- /dev/null +++ b/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm.scss @@ -0,0 +1,33 @@ +@import "common/sass/variables"; + +.AddCustom { + &-field { + &-error { + font-size: 13px; + font-weight: normal; + color: $brand-danger; + } + } + + &-buttons { + padding-top: 10px; + + &-help { + display: block; + font-size: 13px; + margin-bottom: 10px; + } + + &-btn { + margin-right: 10px; + + &.btn-primary { + width: 120px; + } + + &.btn-default { + width: 110px; + } + } + } +} diff --git a/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm.tsx b/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm.tsx index f07cff3b..898f304d 100644 --- a/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm.tsx +++ b/common/components/BalanceSidebar/TokenBalances/AddCustomTokenForm.tsx @@ -1,14 +1,19 @@ +import React from 'react'; import classnames from 'classnames'; import { Token } from 'config/data'; import { isPositiveIntegerOrZero, isValidETHAddress } from 'libs/validators'; -import React from 'react'; import translate from 'translations'; +import NewTabLink from 'components/ui/NewTabLink'; +import './AddCustomTokenForm.scss'; interface Props { + allTokens: Token[]; onSave(params: Token): void; + toggleForm(): void; } interface State { + tokenSymbolLookup: { [symbol: string]: boolean }; address: string; symbol: string; decimal: string; @@ -16,27 +21,36 @@ interface State { export default class AddCustomTokenForm extends React.Component { public state = { + tokenSymbolLookup: {}, address: '', symbol: '', decimal: '' }; + constructor(props: Props) { + super(props); + this.state = { + ...this.state, + tokenSymbolLookup: this.generateSymbolLookup(props.allTokens) + }; + } + public render() { const { address, symbol, decimal } = this.state; const inputClasses = 'AddCustom-field-input form-control input-sm'; const errors = this.getErrors(); const fields = [ - { - name: 'address', - value: address, - label: translate('TOKEN_Addr') - }, { name: 'symbol', value: symbol, label: translate('TOKEN_Symbol') }, + { + name: 'address', + value: address, + label: translate('TOKEN_Addr') + }, { name: 'decimal', value: decimal, @@ -53,50 +67,67 @@ export default class AddCustomTokenForm extends React.Component { + {typeof errors[field.name] === 'string' && ( +
    {errors[field.name]}
    + )} ); })} - +
    + + {translate('Need help? Learn how to add custom tokens.')} + + + +
    ); } public getErrors() { const { address, symbol, decimal } = this.state; - const errors = { - decimal: false, - address: false, - symbol: false - }; + const errors: { [key: string]: boolean | string } = {}; - if (!isPositiveIntegerOrZero(parseInt(decimal, 10))) { + // Formatting errors + if (decimal && !isPositiveIntegerOrZero(parseInt(decimal, 10))) { errors.decimal = true; } - if (!isValidETHAddress(address)) { + if (address && !isValidETHAddress(address)) { errors.address = true; } - if (!symbol) { - errors.symbol = true; + + // Message errors + if (symbol && this.state.tokenSymbolLookup[symbol]) { + errors.symbol = 'A token with this symbol already exists'; } return errors; } public isValid() { - return !Object.keys(this.getErrors()).length; + const { address, symbol, decimal } = this.state; + return !Object.keys(this.getErrors()).length && address && symbol && decimal; } public onFieldChange = (e: React.SyntheticEvent) => { @@ -115,4 +146,11 @@ export default class AddCustomTokenForm extends React.Component { const { address, symbol, decimal } = this.state; this.props.onSave({ address, symbol, decimal: parseInt(decimal, 10) }); }; + + private generateSymbolLookup(tokens: Token[]) { + return tokens.reduce((prev, tk) => { + prev[tk.symbol] = true; + return prev; + }, {}); + } } diff --git a/common/components/BalanceSidebar/TokenBalances/Balances.tsx b/common/components/BalanceSidebar/TokenBalances/Balances.tsx new file mode 100644 index 00000000..4c61c2c9 --- /dev/null +++ b/common/components/BalanceSidebar/TokenBalances/Balances.tsx @@ -0,0 +1,131 @@ +import React from 'react'; +import translate from 'translations'; +import { Token } from 'config/data'; +import { TokenBalance } from 'selectors/wallet'; +import AddCustomTokenForm from './AddCustomTokenForm'; +import TokenRow from './TokenRow'; + +interface Props { + allTokens: Token[]; + tokenBalances: TokenBalance[]; + hasSavedWalletTokens: boolean; + scanWalletForTokens(): any; + setWalletTokens(tokens: string[]): any; + onAddCustomToken(token: Token): any; + onRemoveCustomToken(symbol: string): any; +} + +interface State { + trackedTokens: { [symbol: string]: boolean }; + showCustomTokenForm: boolean; +} +export default class TokenBalances extends React.Component { + public state = { + trackedTokens: {}, + showCustomTokenForm: false + }; + + public componentWillReceiveProps(nextProps: Props) { + if (nextProps.tokenBalances !== this.props.tokenBalances) { + const trackedTokens = nextProps.tokenBalances.reduce((prev, t) => { + prev[t.symbol] = !t.balance.isZero(); + return prev; + }, {}); + this.setState({ trackedTokens }); + } + } + + public render() { + const { allTokens, tokenBalances, hasSavedWalletTokens } = this.props; + const { showCustomTokenForm, trackedTokens } = this.state; + + let bottom; + if (!hasSavedWalletTokens) { + bottom = ( +
    + +

    + {translate('Missing tokens? You can add custom tokens next.')} +

    +
    + ); + } else if (showCustomTokenForm) { + bottom = ( +
    + +
    + ); + } else { + bottom = ( +
    + {' '} + +
    + ); + } + + return ( +
    + {!hasSavedWalletTokens && ( +

    Select which tokens you would like to keep track of

    + )} + + + {tokenBalances.map( + token => + token ? ( + + ) : null + )} + +
    + {bottom} +
    + ); + } + + private toggleTrack = (symbol: string) => { + this.setState({ + trackedTokens: { + ...this.state.trackedTokens, + [symbol]: !this.state.trackedTokens[symbol] + } + }); + }; + + private toggleShowCustomTokenForm = () => { + this.setState({ + showCustomTokenForm: !this.state.showCustomTokenForm + }); + }; + + private addCustomToken = (token: Token) => { + this.props.onAddCustomToken(token); + this.setState({ showCustomTokenForm: false }); + }; + + private handleSetWalletTokens = () => { + const { trackedTokens } = this.state; + const desiredTokens = Object.keys(trackedTokens).filter(t => trackedTokens[t]); + this.props.setWalletTokens(desiredTokens); + }; +} diff --git a/common/components/BalanceSidebar/TokenBalances/TokenRow.scss b/common/components/BalanceSidebar/TokenBalances/TokenRow.scss index 12f7031e..5bc17172 100644 --- a/common/components/BalanceSidebar/TokenBalances/TokenRow.scss +++ b/common/components/BalanceSidebar/TokenBalances/TokenRow.scss @@ -11,21 +11,25 @@ &-balance { @include mono; + } + + &-symbol { + position: relative; + font-weight: 300; &-remove { - margin-left: -32px; - margin-right: 20px; - height: 12px; + position: absolute; + top: 50%; + right: 4px; + float: right; + font-size: 18px; cursor: pointer; opacity: 0.4; + transform: translateY(-50%); &:hover { opacity: 1; } } } - - &-symbol { - font-weight: 300; - } } diff --git a/common/components/BalanceSidebar/TokenBalances/TokenRow.tsx b/common/components/BalanceSidebar/TokenBalances/TokenRow.tsx index 06f0361b..011dd9e4 100644 --- a/common/components/BalanceSidebar/TokenBalances/TokenRow.tsx +++ b/common/components/BalanceSidebar/TokenBalances/TokenRow.tsx @@ -4,11 +4,15 @@ import { TokenValue } from 'libs/units'; import { UnitDisplay } from 'components/ui'; import './TokenRow.scss'; +type ToggleTrackedFn = (symbol: string) => void; + interface Props { balance: TokenValue; symbol: string; custom?: boolean; decimal: number; + tracked: boolean; + toggleTracked: ToggleTrackedFn | false; onRemove(symbol: string): void; } interface State { @@ -21,16 +25,32 @@ export default class TokenRow extends React.Component { }; public render() { - const { balance, symbol, custom, decimal } = this.props; + const { balance, symbol, custom, decimal, tracked } = this.props; const { showLongBalance } = this.state; return ( - + + {this.props.toggleTracked && ( + + + + )} + + + + + + {symbol} {!!custom && ( { tabIndex={0} /> )} - - - - {symbol} ); } @@ -58,7 +74,13 @@ export default class TokenRow extends React.Component { }); }; - public onRemove = () => { + private onRemove = () => { this.props.onRemove(this.props.symbol); }; + + private handleToggleTracked = () => { + if (this.props.toggleTracked) { + this.props.toggleTracked(this.props.symbol); + } + }; } diff --git a/common/components/BalanceSidebar/TokenBalances/index.scss b/common/components/BalanceSidebar/TokenBalances/index.scss index e75cb29b..dfd4d9e8 100644 --- a/common/components/BalanceSidebar/TokenBalances/index.scss +++ b/common/components/BalanceSidebar/TokenBalances/index.scss @@ -5,14 +5,35 @@ margin-top: 0; } + &-help { + font-size: $font-size-small; + margin-bottom: 15px; + } + + &-scan { + margin-top: 10px; + } + + &-loader { + padding: 25px 0; + text-align: center; + } + &-rows { width: 100%; margin-bottom: $space; } &-form { - margin-top: $space * 2; - padding-top: $space; - border-top: 1px solid $gray-lighter; + margin-top: $space; + } + + &-buttons { + &-help { + padding-top: 10px; + text-align: center; + font-size: $font-size-xs; + color: $gray; + } } } diff --git a/common/components/BalanceSidebar/TokenBalances/index.tsx b/common/components/BalanceSidebar/TokenBalances/index.tsx index a8920dbd..4eaa3ced 100644 --- a/common/components/BalanceSidebar/TokenBalances/index.tsx +++ b/common/components/BalanceSidebar/TokenBalances/index.tsx @@ -1,93 +1,120 @@ -import { Token } from 'config/data'; import React from 'react'; -import { TokenBalance } from 'selectors/wallet'; +import { connect } from 'react-redux'; +import { AppState } from 'reducers'; +import { + addCustomToken, + removeCustomToken, + TAddCustomToken, + TRemoveCustomToken +} from 'actions/customTokens'; +import { + scanWalletForTokens, + TScanWalletForTokens, + setWalletTokens, + TSetWalletTokens +} from 'actions/wallet'; +import { getAllTokens } from 'selectors/config'; +import { getTokenBalances, getWalletInst, getWalletConfig, TokenBalance } from 'selectors/wallet'; +import { Token } from 'config/data'; import translate from 'translations'; -import AddCustomTokenForm from './AddCustomTokenForm'; +import Balances from './Balances'; +import Spinner from 'components/ui/Spinner'; import './index.scss'; -import TokenRow from './TokenRow'; -interface Props { - tokens: TokenBalance[]; - onAddCustomToken(token: Token): any; - onRemoveCustomToken(symbol: string): any; +interface StateProps { + wallet: AppState['wallet']['inst']; + walletConfig: AppState['wallet']['config']; + tokens: Token[]; + tokenBalances: TokenBalance[]; + tokensError: AppState['wallet']['tokensError']; + isTokensLoading: AppState['wallet']['isTokensLoading']; + hasSavedWalletTokens: AppState['wallet']['hasSavedWalletTokens']; } - -interface State { - showAllTokens: boolean; - showCustomTokenForm: boolean; +interface ActionProps { + addCustomToken: TAddCustomToken; + removeCustomToken: TRemoveCustomToken; + scanWalletForTokens: TScanWalletForTokens; + setWalletTokens: TSetWalletTokens; } -export default class TokenBalances extends React.Component { - public state = { - showAllTokens: false, - showCustomTokenForm: false - }; +type Props = StateProps & ActionProps; +class TokenBalances extends React.Component { public render() { - const { tokens } = this.props; - const shownTokens = tokens.filter( - token => !token.balance.eqn(0) || token.custom || this.state.showAllTokens - ); + const { + tokens, + walletConfig, + tokenBalances, + hasSavedWalletTokens, + isTokensLoading, + tokensError + } = this.props; + + const walletTokens = walletConfig ? walletConfig.tokens : []; + + let content; + if (tokensError) { + content =
    {tokensError}
    ; + } else if (isTokensLoading) { + content = ( +
    + +
    + ); + } else if (!walletTokens) { + content = ( + + ); + } else { + const shownBalances = tokenBalances.filter(t => walletTokens.includes(t.symbol)); + + content = ( + + ); + } return (
    {translate('sidebar_TokenBal')}
    - - - {shownTokens.map(token => ( - - ))} - -
    - -
    - {' '} - -
    - - {this.state.showCustomTokenForm && ( -
    - -
    - )} + {content}
    ); } - public toggleShowAllTokens = () => { - this.setState(state => { - return { - showAllTokens: !state.showAllTokens - }; - }); - }; - - public toggleShowCustomTokenForm = () => { - this.setState(state => { - return { - showCustomTokenForm: !state.showCustomTokenForm - }; - }); - }; - - public addCustomToken = (token: Token) => { - this.props.onAddCustomToken(token); - this.setState({ showCustomTokenForm: false }); + private scanWalletForTokens = () => { + if (this.props.wallet) { + this.props.scanWalletForTokens(this.props.wallet); + } }; } + +function mapStateToProps(state: AppState): StateProps { + return { + wallet: getWalletInst(state), + walletConfig: getWalletConfig(state), + tokens: getAllTokens(state), + tokenBalances: getTokenBalances(state), + tokensError: state.wallet.tokensError, + isTokensLoading: state.wallet.isTokensLoading, + hasSavedWalletTokens: state.wallet.hasSavedWalletTokens + }; +} + +export default connect(mapStateToProps, { + addCustomToken, + removeCustomToken, + scanWalletForTokens, + setWalletTokens +})(TokenBalances); diff --git a/common/components/BalanceSidebar/index.tsx b/common/components/BalanceSidebar/index.tsx index 7fab773d..3221afb3 100644 --- a/common/components/BalanceSidebar/index.tsx +++ b/common/components/BalanceSidebar/index.tsx @@ -1,22 +1,11 @@ -import { - addCustomToken, - removeCustomToken, - TAddCustomToken, - TRemoveCustomToken -} from 'actions/customTokens'; -import { showNotification, TShowNotification } from 'actions/notifications'; -import { fetchCCRates as dFetchCCRates, TFetchCCRates } from 'actions/rates'; +import { fetchCCRates, TFetchCCRates } from 'actions/rates'; import { NetworkConfig } from 'config/data'; import { IWallet, Balance } from 'libs/wallet'; import React from 'react'; import { connect } from 'react-redux'; import { AppState } from 'reducers'; import { getNetworkConfig } from 'selectors/config'; -import { - getTokenBalances, - getWalletInst, - TokenBalance -} from 'selectors/wallet'; +import { getShownTokenBalances, getWalletInst, TokenBalance } from 'selectors/wallet'; import AccountInfo from './AccountInfo'; import EquivalentValues from './EquivalentValues'; import Promos from './Promos'; @@ -30,9 +19,6 @@ interface Props { tokenBalances: TokenBalance[]; rates: AppState['rates']['rates']; ratesError: AppState['rates']['ratesError']; - showNotification: TShowNotification; - addCustomToken: TAddCustomToken; - removeCustomToken: TRemoveCustomToken; fetchCCRates: TFetchCCRates; } @@ -44,15 +30,8 @@ interface Block { export class BalanceSidebar extends React.Component { public render() { - const { - wallet, - balance, - network, - tokenBalances, - rates, - ratesError, - fetchCCRates - } = this.props; + const { wallet, balance, network, tokenBalances, rates, ratesError } = this.props; + if (!wallet) { return null; } @@ -64,9 +43,7 @@ export class BalanceSidebar extends React.Component { }, { name: 'Account Info', - content: ( - - ) + content: }, { name: 'Promos', @@ -75,13 +52,7 @@ export class BalanceSidebar extends React.Component { }, { name: 'Token Balances', - content: ( - - ) + content: }, { name: 'Equivalent Values', @@ -91,7 +62,7 @@ export class BalanceSidebar extends React.Component { tokenBalances={tokenBalances} rates={rates} ratesError={ratesError} - fetchCCRates={fetchCCRates} + fetchCCRates={this.props.fetchCCRates} /> ) } @@ -100,10 +71,7 @@ export class BalanceSidebar extends React.Component { return (