From fc50202f6ac7c72d690993e70e156f3e4335b303 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Sat, 17 Nov 2018 17:29:28 +0100 Subject: [PATCH] Added action --- src/actions/SendFormActions.js | 18 ++++++++++++++++++ .../Send/components/AdvancedForm/index.js | 6 +++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/actions/SendFormActions.js b/src/actions/SendFormActions.js index 3413ed36..cdea6602 100644 --- a/src/actions/SendFormActions.js +++ b/src/actions/SendFormActions.js @@ -384,6 +384,23 @@ export const onDataChange = (data: string): ThunkAction => (dispatch: Dispatch, dispatch(estimateGasPrice()); }; +export const setDefaultGasLimit = (): ThunkAction => (dispatch: Dispatch, getState: GetState): void => { + const state: State = getState().sendForm; + const { network } = getState().selectedAccount; + if (!network) return; + + dispatch({ + type: SEND.CHANGE, + state: { + ...state, + calculatingGasLimit: false, + untouched: false, + touched: { ...state.touched, gasLimit: true }, + gasLimit: network.defaultGasLimit.toString(), + }, + }); +}; + /* * Internal method * Called from "onDataChange" action @@ -548,6 +565,7 @@ export default { updateFeeLevels, onGasPriceChange, onGasLimitChange, + setDefaultGasLimit, onNonceChange, onDataChange, onSend, diff --git a/src/views/Wallet/views/Account/Send/components/AdvancedForm/index.js b/src/views/Wallet/views/Account/Send/components/AdvancedForm/index.js index 380ac123..0e9ea9e0 100644 --- a/src/views/Wallet/views/Account/Send/components/AdvancedForm/index.js +++ b/src/views/Wallet/views/Account/Send/components/AdvancedForm/index.js @@ -143,11 +143,11 @@ const AdvancedForm = (props: Props) => { gasPrice, } = props.sendForm; const { + setDefaultGasLimit, onGasLimitChange, onGasPriceChange, onDataChange, } = props.sendFormActions; - let gasLimitTooltipCurrency: string; let gasLimitTooltipValue: string; if (networkSymbol !== currency) { @@ -190,8 +190,8 @@ const AdvancedForm = (props: Props) => { /> - - Set default + setDefaultGasLimit()}> + Set default )}