@@ -11,7 +11,19 @@ import {
11
11
import { NetworkType } from '@suite-common/wallet-config' ;
12
12
import { FeeInfo , FormState } from '@suite-common/wallet-types' ;
13
13
import { getFeeUnits , getInputState , isInteger } from '@suite-common/wallet-utils' ;
14
- import { Banner , Column , Grid , Note , Text , useMediaQuery , variables } from '@trezor/components' ;
14
+ import {
15
+ Banner ,
16
+ Column ,
17
+ Grid ,
18
+ Icon ,
19
+ Note ,
20
+ Row ,
21
+ Text ,
22
+ useElevation ,
23
+ useMediaQuery ,
24
+ variables ,
25
+ } from '@trezor/components' ;
26
+ import { FeeLevel } from '@trezor/connect' ;
15
27
import { NumberInput } from '@trezor/product-components' ;
16
28
import { spacings } from '@trezor/theme' ;
17
29
import { HELP_CENTER_TRANSACTION_FEES_URL } from '@trezor/urls' ;
@@ -23,6 +35,7 @@ import { useSelector, useTranslation } from 'src/hooks/suite';
23
35
import { selectLanguage } from 'src/reducers/suite/suiteReducer' ;
24
36
import { validateDecimals } from 'src/utils/suite/validation' ;
25
37
38
+ import { BorderTopWrapper } from './Fees' ;
26
39
import { InputError } from '../InputError' ;
27
40
28
41
const FEE_PER_UNIT = 'feePerUnit' ;
@@ -36,16 +49,22 @@ interface CustomFeeProps<TFieldValues extends FormState> {
36
49
control : Control ;
37
50
setValue : UseFormSetValue < TFieldValues > ;
38
51
getValues : UseFormGetValues < TFieldValues > ;
39
- changeFeeLimit ?: ( value : string ) => void ;
40
52
composedFeePerByte : string ;
41
53
}
42
54
55
+ const getAverageFee = ( levels : FeeLevel [ ] ) => {
56
+ if ( levels . length > 2 ) {
57
+ return `${ levels [ 1 ] . feePerUnit } ` ;
58
+ }
59
+
60
+ return `${ levels [ 0 ] . feePerUnit } ` ;
61
+ } ;
62
+
43
63
export const CustomFee = < TFieldValues extends FormState > ( {
44
64
networkType,
45
65
feeInfo,
46
66
register,
47
67
control,
48
- changeFeeLimit,
49
68
composedFeePerByte,
50
69
...props
51
70
} : CustomFeeProps < TFieldValues > ) => {
@@ -66,6 +85,7 @@ export const CustomFee = <TFieldValues extends FormState>({
66
85
67
86
const feePerUnitError = errors . feePerUnit ;
68
87
const feeLimitError = errors . feeLimit ;
88
+ const { elevation } = useElevation ( ) ;
69
89
70
90
const useFeeLimit = networkType === 'ethereum' ;
71
91
const isComposedFeeRateDifferent =
@@ -146,7 +166,7 @@ export const CustomFee = <TFieldValues extends FormState>({
146
166
feeLimitError ?. type === 'feeLimit' ? feeLimitValidationProps : undefined ;
147
167
148
168
return (
149
- < Column gap = { spacings . xs } >
169
+ < Column gap = { spacings . md } margin = { { bottom : spacings . md } } >
150
170
< Banner
151
171
icon
152
172
variant = "warning"
@@ -160,6 +180,35 @@ export const CustomFee = <TFieldValues extends FormState>({
160
180
>
161
181
< Translation id = "TR_CUSTOM_FEE_WARNING" />
162
182
</ Banner >
183
+ < BorderTopWrapper $elevation = { elevation } >
184
+ < Row
185
+ justifyContent = "space-between"
186
+ margin = { {
187
+ left : spacings . md ,
188
+ right : spacings . md ,
189
+ } }
190
+ >
191
+ < Text variant = "tertiary" >
192
+ < Translation
193
+ id = {
194
+ networkType === 'ethereum'
195
+ ? 'TR_AVERAGE_GAS_PRICE'
196
+ : 'TR_AVERAGE_FEE'
197
+ }
198
+ />
199
+ :
200
+ </ Text >
201
+ < Text variant = "tertiary" >
202
+ < Row alignItems = "center" gap = { spacings . xxs } >
203
+ { getAverageFee ( feeInfo . levels ) } { getFeeUnits ( networkType ) }
204
+ < Icon
205
+ name = { networkType === 'ethereum' ? 'gasPump' : 'receipt' }
206
+ size = "mediumLarge"
207
+ />
208
+ </ Row >
209
+ </ Text >
210
+ </ Row >
211
+ </ BorderTopWrapper >
163
212
< Grid gap = { spacings . xs } columns = { useFeeLimit && ! isBelowLaptop ? 2 : 1 } >
164
213
{ useFeeLimit ? (
165
214
< NumberInput
@@ -169,7 +218,6 @@ export const CustomFee = <TFieldValues extends FormState>({
169
218
inputState = { getInputState ( feeLimitError ) }
170
219
name = { FEE_LIMIT }
171
220
data-testid = { FEE_LIMIT }
172
- onChange = { changeFeeLimit }
173
221
bottomText = {
174
222
feeLimitError ?. message ? (
175
223
< InputError
0 commit comments