From eaa6e19050fbba349046b18514a807e601c20795 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Wed, 9 May 2018 16:36:25 +0200 Subject: [PATCH] Sendform coinsymbol & set max fix --- src/js/actions/SendFormActions.js | 23 ++++++++++------------- src/js/components/modal/ConfirmSignTx.js | 2 +- src/js/components/wallet/send/SendForm.js | 2 +- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/js/actions/SendFormActions.js b/src/js/actions/SendFormActions.js index cb6810c9..e2a25132 100644 --- a/src/js/actions/SendFormActions.js +++ b/src/js/actions/SendFormActions.js @@ -195,7 +195,7 @@ export const init = (): ThunkAction => { ...initialState, network: coin.network, coinSymbol: coin.symbol, - token: coin.network, + token: coin.symbol, feeLevels, selectedFeeLevel: feeLevels.find(f => f.value === 'Normal'), recommendedGasPrice: gasPrice.toString(), @@ -384,7 +384,7 @@ export const onAmountChange = (amount: string): ThunkAction => { const accountState: AccountState = getState().abstractAccount; const currentState: State = getState().sendForm; - const isToken: boolean = currentState.token !== accountState.network; + const isToken: boolean = currentState.token !== currentState.coinSymbol; const touched = { ...currentState.touched }; touched.amount = true; const total: string = calculateTotal(isToken ? '0' : amount, currentState.gasPrice, currentState.gasLimit); @@ -410,7 +410,7 @@ export const onCurrencyChange = (currency: any): ThunkAction => { return (dispatch: Dispatch, getState: GetState): void => { const accountState: AccountState = getState().abstractAccount; const currentState: State = getState().sendForm; - const isToken: boolean = currency.value !== accountState.network; + const isToken: boolean = currency.value !== currentState.coinSymbol; const account: ?Account = findAccount(getState().accounts, accountState.index, accountState.deviceState, accountState.network); if (!account) { @@ -418,10 +418,7 @@ export const onCurrencyChange = (currency: any): ThunkAction => { return; } - const { config } = getState().localStorage; - if (!config) return; - const coin: ?Coin = config.coins.find(c => c.network === accountState.network); - if (!coin) return; + const coin: Coin = accountState.coin; let gasLimit: string = ''; let amount: string = currentState.amount; @@ -430,7 +427,7 @@ export const onCurrencyChange = (currency: any): ThunkAction => { if (isToken) { gasLimit = coin.defaultGasLimitTokens.toString(); if (currentState.setMax) { - const token: ?Token = findToken(getState().tokens, account.address, currentState.token, accountState.deviceState); + const token: ?Token = findToken(getState().tokens, account.address, currency.value, accountState.deviceState); if (!token) return; amount = token.balance; } @@ -471,7 +468,7 @@ export const onSetMax = (): ThunkAction => { return (dispatch: Dispatch, getState: GetState): void => { const accountState: AccountState = getState().abstractAccount; const currentState: State = getState().sendForm; - const isToken: boolean = currentState.token !== accountState.network; + const isToken: boolean = currentState.token !== currentState.coinSymbol; const touched = { ...currentState.touched }; touched.amount = true; @@ -516,7 +513,7 @@ export const onFeeLevelChange = (feeLevel: FeeLevel): ThunkAction => { return (dispatch: Dispatch, getState: GetState): void => { const accountState: AccountState = getState().abstractAccount; const currentState: State = getState().sendForm; - const isToken: boolean = currentState.token !== accountState.network; + const isToken: boolean = currentState.token !== currentState.coinSymbol; const { config } = getState().localStorage; if (!config) return; @@ -569,7 +566,7 @@ export const updateFeeLevels = (): ThunkAction => { return (dispatch: Dispatch, getState: GetState): void => { const accountState: AccountState = getState().abstractAccount; const currentState: State = getState().sendForm; - const isToken: boolean = currentState.token !== accountState.network; + const isToken: boolean = currentState.token !== currentState.coinSymbol; const feeLevels: Array = getFeeLevels(currentState.coinSymbol, currentState.recommendedGasPrice, currentState.gasLimit); const selectedFeeLevel: ?FeeLevel = feeLevels.find(f => f.value === currentState.selectedFeeLevel.value); @@ -658,7 +655,7 @@ export const onGasLimitChange = (gasLimit: string): ThunkAction => { return (dispatch: Dispatch, getState: GetState): void => { const accountState: AccountState = getState().abstractAccount; const currentState: State = getState().sendForm; - const isToken: boolean = currentState.token !== accountState.network; + const isToken: boolean = currentState.token !== currentState.coinSymbol; const touched = { ...currentState.touched }; touched.gasLimit = true; @@ -733,7 +730,7 @@ export const onSend = (): AsyncAction => { const account: ?Account = findAccount(getState().accounts, accountState.index, accountState.deviceState, accountState.network); if (!account || !web3instance) return; - const isToken: boolean = currentState.token !== accountState.network; + const isToken: boolean = currentState.token !== currentState.coinSymbol; const web3 = web3instance.web3; const address_n = account.addressPath; diff --git a/src/js/components/modal/ConfirmSignTx.js b/src/js/components/modal/ConfirmSignTx.js index c90861e4..f7647e03 100644 --- a/src/js/components/modal/ConfirmSignTx.js +++ b/src/js/components/modal/ConfirmSignTx.js @@ -23,7 +23,7 @@ const Confirmation = (props: Props) => {
-

{ `${amount} ${ coinSymbol }` }

+

{ `${amount} ${ token }` }

{ address }

diff --git a/src/js/components/wallet/send/SendForm.js b/src/js/components/wallet/send/SendForm.js index 624058af..cc41e8a2 100644 --- a/src/js/components/wallet/send/SendForm.js +++ b/src/js/components/wallet/send/SendForm.js @@ -66,7 +66,7 @@ const _render = (props: Props, state: AccountState): React$Element => { const tokens = addressTokens.map(t => { return { value: t.symbol, label: t.symbol }; }); - tokens.unshift({ value: selectedCoin.network, label: selectedCoin.symbol }); + tokens.unshift({ value: selectedCoin.symbol, label: selectedCoin.symbol }); const setMaxClassName: string = setMax ? 'set-max enabled' : 'set-max';