|
|
|
@ -53,13 +53,6 @@ export const observe = (prevState: ReducersState, action: Action): ThunkAction =
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// clear transaction draft from session storage and reinitialize send form
|
|
|
|
|
if (action.type === SEND.CLEAR) {
|
|
|
|
|
dispatch(SessionStorageActions.clear());
|
|
|
|
|
dispatch(init());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if send form was not initialized
|
|
|
|
|
if (currentState.sendFormEthereum.currency === '') {
|
|
|
|
|
dispatch(init());
|
|
|
|
@ -116,8 +109,6 @@ export const init = (): AsyncAction => async (dispatch: Dispatch, getState: GetS
|
|
|
|
|
network,
|
|
|
|
|
} = getState().selectedAccount;
|
|
|
|
|
|
|
|
|
|
const { advanced } = getState().sendFormEthereum;
|
|
|
|
|
|
|
|
|
|
if (!account || !network) return;
|
|
|
|
|
|
|
|
|
|
const stateFromStorage = dispatch(SessionStorageActions.loadEthereumDraftTransaction());
|
|
|
|
@ -149,7 +140,6 @@ export const init = (): AsyncAction => async (dispatch: Dispatch, getState: GetS
|
|
|
|
|
recommendedGasPrice: gasPrice.toString(),
|
|
|
|
|
gasLimit,
|
|
|
|
|
gasPrice: gasPrice.toString(),
|
|
|
|
|
advanced,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
@ -165,10 +155,37 @@ export const toggleAdvanced = (): Action => ({
|
|
|
|
|
/*
|
|
|
|
|
* Called from UI from "clear" button
|
|
|
|
|
*/
|
|
|
|
|
export const onClear = (): Action => ({
|
|
|
|
|
type: SEND.CLEAR,
|
|
|
|
|
networkType: 'ethereum',
|
|
|
|
|
});
|
|
|
|
|
export const onClear = (): AsyncAction => async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
|
|
|
|
const { network } = getState().selectedAccount;
|
|
|
|
|
const { advanced } = getState().sendFormEthereum;
|
|
|
|
|
|
|
|
|
|
if (!network) return;
|
|
|
|
|
|
|
|
|
|
// clear transaction draft from session storage
|
|
|
|
|
dispatch(SessionStorageActions.clear());
|
|
|
|
|
|
|
|
|
|
const gasPrice: BigNumber = await dispatch(BlockchainActions.getGasPrice(network.shortcut, network.defaultGasPrice));
|
|
|
|
|
const gasLimit = network.defaultGasLimit.toString();
|
|
|
|
|
const feeLevels = ValidationActions.getFeeLevels(network.symbol, gasPrice, gasLimit);
|
|
|
|
|
const selectedFeeLevel = ValidationActions.getSelectedFeeLevel(feeLevels, initialState.selectedFeeLevel);
|
|
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
|
type: SEND.CLEAR,
|
|
|
|
|
networkType: 'ethereum',
|
|
|
|
|
state: {
|
|
|
|
|
...initialState,
|
|
|
|
|
networkName: network.shortcut,
|
|
|
|
|
networkSymbol: network.symbol,
|
|
|
|
|
currency: network.symbol,
|
|
|
|
|
feeLevels,
|
|
|
|
|
selectedFeeLevel,
|
|
|
|
|
recommendedGasPrice: gasPrice.toString(),
|
|
|
|
|
gasLimit,
|
|
|
|
|
gasPrice: gasPrice.toString(),
|
|
|
|
|
advanced,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Called from UI on "address" field change
|
|
|
|
|