@@ -35,12 +35,14 @@ import { useSelector, useTranslation } from 'src/hooks/suite';
35
35
import { selectLanguage } from 'src/reducers/suite/suiteReducer' ;
36
36
import { validateDecimals } from 'src/utils/suite/validation' ;
37
37
38
- import { BorderTopWrapper } from './Fees' ;
39
38
import { InputError } from '../InputError' ;
40
39
41
40
const FEE_PER_UNIT = 'feePerUnit' ;
42
41
const FEE_LIMIT = 'feeLimit' ;
43
42
43
+ const MAX_FEE_PER_GAS = 'maxFeePerGas' ;
44
+ const MAX_PRIORITY_FEE_PER_GAS = 'maxPriorityFeePerGas' ;
45
+
44
46
interface CustomFeeProps < TFieldValues extends FormState > {
45
47
networkType : NetworkType ;
46
48
feeInfo : FeeInfo ;
@@ -50,6 +52,7 @@ interface CustomFeeProps<TFieldValues extends FormState> {
50
52
setValue : UseFormSetValue < TFieldValues > ;
51
53
getValues : UseFormGetValues < TFieldValues > ;
52
54
composedFeePerByte : string ;
55
+ shouldUsePriorityFees ?: boolean ;
53
56
}
54
57
55
58
const getAverageFee = ( levels : FeeLevel [ ] ) => `${ levels [ levels . length > 2 ? 1 : 0 ] . feePerUnit } ` ;
@@ -60,13 +63,16 @@ export const CustomFee = <TFieldValues extends FormState>({
60
63
register,
61
64
control,
62
65
composedFeePerByte,
66
+ shouldUsePriorityFees = false ,
63
67
...props
64
68
} : CustomFeeProps < TFieldValues > ) => {
65
69
const { translationString } = useTranslation ( ) ;
66
70
const isBelowLaptop = useMediaQuery ( `(max-width: ${ variables . SCREEN_SIZE . LG } )` ) ;
67
71
68
72
const locale = useSelector ( selectLanguage ) ;
69
73
74
+ console . log ( 'feeInfo' , feeInfo ) ;
75
+
70
76
// Type assertion allowing to make the component reusable, see https://stackoverflow.com/a/73624072.
71
77
const { getValues, setValue } = props as unknown as UseFormReturn < FormState > ;
72
78
const errors = props . errors as unknown as FieldErrors < FormState > ;
@@ -77,9 +83,13 @@ export const CustomFee = <TFieldValues extends FormState>({
77
83
const feeUnits = getFeeUnits ( networkType ) ;
78
84
const estimatedFeeLimit = getValues ( 'estimatedFeeLimit' ) ;
79
85
86
+ // const maxFeePerGas = shouldUsePriorityFees ? getValues(MAX_FEE_PER_GAS) : undefined; //only for priority fees on evms
87
+ // const maxPriorityFeePerGas = shouldUsePriorityFees
88
+ // ? getValues(MAX_PRIORITY_FEE_PER_GAS)
89
+ // : undefined;
90
+
80
91
const feePerUnitError = errors . feePerUnit ;
81
92
const feeLimitError = errors . feeLimit ;
82
- const { elevation } = useElevation ( ) ;
83
93
84
94
const useFeeLimit = networkType === 'ethereum' ;
85
95
const isComposedFeeRateDifferent =
@@ -219,21 +229,57 @@ export const CustomFee = <TFieldValues extends FormState>({
219
229
) : (
220
230
< input type = "hidden" { ...register ( FEE_LIMIT as FieldPath < TFieldValues > ) } />
221
231
) }
222
- < NumberInput
223
- label = { useFeeLimit ? < Translation id = "TR_GAS_PRICE" /> : undefined }
224
- locale = { locale }
225
- control = { control }
226
- inputState = { getInputState ( feePerUnitError ) }
227
- innerAddon = {
228
- < Text variant = "tertiary" typographyStyle = "label" >
229
- { feeUnits }
230
- </ Text >
231
- }
232
- name = { FEE_PER_UNIT }
233
- data-testid = { FEE_PER_UNIT }
234
- rules = { feeRules }
235
- bottomText = { feePerUnitError ?. message || null }
236
- />
232
+
233
+ { shouldUsePriorityFees && feeInfo . levels [ 0 ] . ethFeeType === 'eip1559' ? (
234
+ < >
235
+ < NumberInput
236
+ label = { < Translation id = "TR_MAX_PRIORITY_FEE_PER_GAS" /> }
237
+ locale = { locale }
238
+ control = { control }
239
+ inputState = { getInputState ( feePerUnitError ) }
240
+ innerAddon = {
241
+ < Text variant = "tertiary" typographyStyle = "label" >
242
+ { feeUnits }
243
+ </ Text >
244
+ }
245
+ name = { MAX_PRIORITY_FEE_PER_GAS }
246
+ data-testid = { MAX_PRIORITY_FEE_PER_GAS }
247
+ rules = { feeRules }
248
+ bottomText = { feePerUnitError ?. message || null }
249
+ />
250
+ < NumberInput
251
+ label = { < Translation id = "TR_MAX_FEE_PER_GAS" /> }
252
+ locale = { locale }
253
+ control = { control }
254
+ inputState = { getInputState ( feePerUnitError ) }
255
+ innerAddon = {
256
+ < Text variant = "tertiary" typographyStyle = "label" >
257
+ { feeUnits }
258
+ </ Text >
259
+ }
260
+ name = { MAX_FEE_PER_GAS }
261
+ data-testid = { MAX_FEE_PER_GAS }
262
+ rules = { feeRules }
263
+ bottomText = { feePerUnitError ?. message || null }
264
+ />
265
+ </ >
266
+ ) : (
267
+ < NumberInput
268
+ label = { useFeeLimit ? < Translation id = "TR_GAS_PRICE" /> : undefined }
269
+ locale = { locale }
270
+ control = { control }
271
+ inputState = { getInputState ( feePerUnitError ) }
272
+ innerAddon = {
273
+ < Text variant = "tertiary" typographyStyle = "label" >
274
+ { feeUnits }
275
+ </ Text >
276
+ }
277
+ name = { FEE_PER_UNIT }
278
+ data-testid = { FEE_PER_UNIT }
279
+ rules = { feeRules }
280
+ bottomText = { feePerUnitError ?. message || null }
281
+ />
282
+ ) }
237
283
</ Grid >
238
284
{ feeDifferenceWarning && < Note > { feeDifferenceWarning } </ Note > }
239
285
</ Column >
0 commit comments