From 2b0ca58c35c2fe74fe4898259dfa3547c244ca98 Mon Sep 17 00:00:00 2001 From: Alec Charbonneau Date: Fri, 20 May 2022 14:55:33 -0700 Subject: [PATCH 1/3] use recommended transaction fee by default --- .../SendSettings/TransactionFee/index.tsx | 3 ++- .../components/sendPayment/SendSettings/index.tsx | 12 +++++++++++- extension/src/popup/ducks/transactionSubmission.ts | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/extension/src/popup/components/sendPayment/SendSettings/TransactionFee/index.tsx b/extension/src/popup/components/sendPayment/SendSettings/TransactionFee/index.tsx index 6dd94ce01d..6adfe58dad 100644 --- a/extension/src/popup/components/sendPayment/SendSettings/TransactionFee/index.tsx +++ b/extension/src/popup/components/sendPayment/SendSettings/TransactionFee/index.tsx @@ -58,7 +58,7 @@ export const SendSettingsFee = () => { navigateTo(ROUTES.sendPaymentSettings); }} > - {({ setFieldValue }) => ( + {({ setFieldValue, dirty }) => (
@@ -74,6 +74,7 @@ export const SendSettingsFee = () => {
setFieldValue("transactionFee", recommendedFee) diff --git a/extension/src/popup/components/sendPayment/SendSettings/index.tsx b/extension/src/popup/components/sendPayment/SendSettings/index.tsx index 61dd03acb5..a140df685b 100644 --- a/extension/src/popup/components/sendPayment/SendSettings/index.tsx +++ b/extension/src/popup/components/sendPayment/SendSettings/index.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useEffect } from "react"; import { useSelector, useDispatch } from "react-redux"; import { Formik, Form, Field, FieldProps } from "formik"; import { @@ -10,6 +10,7 @@ import { import { Button } from "popup/basics/buttons/Button"; import { navigateTo } from "popup/helpers/navigate"; +import { useNetworkFees } from "popup/helpers/useNetworkFees"; import { ROUTES } from "popup/constants/routes"; import { PopupWrapper } from "popup/basics/PopupWrapper"; import { SubviewHeader } from "popup/components/SubviewHeader"; @@ -18,6 +19,7 @@ import { saveMemo, transactionDataSelector, isPathPaymentSelector, + saveTransactionFee, } from "popup/ducks/transactionSubmission"; import "../styles.scss"; @@ -28,6 +30,14 @@ export const SendSettings = ({ previous }: { previous: ROUTES }) => { transactionDataSelector, ); const isPathPayment = useSelector(isPathPaymentSelector); + const { recommendedFee } = useNetworkFees(); + + // use default transaction fee if unset + useEffect(() => { + if (!transactionFee) { + dispatch(saveTransactionFee(recommendedFee)); + } + }, [dispatch, recommendedFee, transactionFee]); return ( diff --git a/extension/src/popup/ducks/transactionSubmission.ts b/extension/src/popup/ducks/transactionSubmission.ts index 0eb2d70932..b0b8939a91 100644 --- a/extension/src/popup/ducks/transactionSubmission.ts +++ b/extension/src/popup/ducks/transactionSubmission.ts @@ -192,7 +192,7 @@ const initialState: InitialState = { asset: "native", destination: "", federationAddress: "", - transactionFee: "0.00001", + transactionFee: "", memo: "", destinationAsset: "", destinationAmount: "", From 3e05fd3f4a68ad503367270f6c77d5b56173d7b7 Mon Sep 17 00:00:00 2001 From: Alec Charbonneau Date: Mon, 23 May 2022 09:31:50 -0700 Subject: [PATCH 2/3] better conditional --- .../SendSettings/TransactionFee/index.tsx | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/extension/src/popup/components/sendPayment/SendSettings/TransactionFee/index.tsx b/extension/src/popup/components/sendPayment/SendSettings/TransactionFee/index.tsx index 6adfe58dad..f3732dd716 100644 --- a/extension/src/popup/components/sendPayment/SendSettings/TransactionFee/index.tsx +++ b/extension/src/popup/components/sendPayment/SendSettings/TransactionFee/index.tsx @@ -58,32 +58,34 @@ export const SendSettingsFee = () => { navigateTo(ROUTES.sendPaymentSettings); }} > - {({ setFieldValue, dirty }) => ( + {({ setFieldValue }) => ( {({ field }: FieldProps) => ( - + <> + +
+ + setFieldValue("transactionFee", recommendedFee) + } + > + Set recommended + + {networkCongestion} congestion +
+ )}
-
- - setFieldValue("transactionFee", recommendedFee) - } - > - Set recommended - - {networkCongestion} congestion -