Skip to content

Commit 8b615ab

Browse files
committed
feat(suite): WIP frontend
1 parent a56ae2b commit 8b615ab

File tree

10 files changed

+448
-177
lines changed

10 files changed

+448
-177
lines changed

packages/connect/src/api/bitcoin/Fees.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class FeeLevels {
8686
if (response.eip1559) {
8787
const eip1559LevelKeys = ['low', 'medium', 'high'] as const;
8888

89-
const { eip1559, ...baseLevel } = response;
89+
const { eip1559 } = response;
9090
const eip1559Levels = eip1559LevelKeys.map(levelKey => {
9191
const level = eip1559[levelKey];
9292

@@ -104,10 +104,7 @@ export class FeeLevels {
104104
};
105105
});
106106

107-
this.levels = [
108-
{ ...baseLevel, label: 'normal' as const, blocks: -1, ethFeeType: 'legacy' },
109-
...eip1559Levels,
110-
];
107+
this.levels = [...eip1559Levels];
111108
} else {
112109
this.levels[0] = {
113110
...this.levels[0],

packages/suite/src/components/wallet/Fees/CustomFee.tsx

+66-18
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from 'react-hook-form';
1010

1111
import { BigNumber } from '@trezor/utils/src/bigNumber';
12-
import { Note, Banner, variables, Grid, Column, useMediaQuery, Text } from '@trezor/components';
12+
import { Note, Banner, Grid, Column, Text } from '@trezor/components';
1313
import { getInputState, getFeeUnits, isInteger } from '@suite-common/wallet-utils';
1414
import { FeeInfo, FormState } from '@suite-common/wallet-types';
1515
import { NetworkType } from '@suite-common/wallet-config';
@@ -28,6 +28,9 @@ import { InputError } from '../InputError';
2828
const FEE_PER_UNIT = 'feePerUnit';
2929
const FEE_LIMIT = 'feeLimit';
3030

31+
const MAX_FEE_PER_GAS = 'maxFeePerGas';
32+
const MAX_PRIORITY_FEE_PER_GAS = 'maxPriorityFeePerGas';
33+
3134
interface CustomFeeProps<TFieldValues extends FormState> {
3235
networkType: NetworkType;
3336
feeInfo: FeeInfo;
@@ -38,6 +41,7 @@ interface CustomFeeProps<TFieldValues extends FormState> {
3841
getValues: UseFormGetValues<TFieldValues>;
3942
changeFeeLimit?: (value: string) => void;
4043
composedFeePerByte: string;
44+
shouldUsePriorityFees: boolean;
4145
}
4246

4347
export const CustomFee = <TFieldValues extends FormState>({
@@ -47,10 +51,11 @@ export const CustomFee = <TFieldValues extends FormState>({
4751
control,
4852
changeFeeLimit,
4953
composedFeePerByte,
54+
shouldUsePriorityFees = false,
5055
...props
5156
}: CustomFeeProps<TFieldValues>) => {
5257
const { translationString } = useTranslation();
53-
const isBelowLaptop = useMediaQuery(`(max-width: ${variables.SCREEN_SIZE.LG})`);
58+
// const isBelowLaptop = useMediaQuery(`(max-width: ${variables.SCREEN_SIZE.LG})`);
5459

5560
const locale = useSelector(selectLanguage);
5661

@@ -64,6 +69,13 @@ export const CustomFee = <TFieldValues extends FormState>({
6469
const feeUnits = getFeeUnits(networkType);
6570
const estimatedFeeLimit = getValues('estimatedFeeLimit');
6671

72+
const maxFeePerGas = shouldUsePriorityFees ? getValues(MAX_FEE_PER_GAS) : undefined; //only for priority fees on evms
73+
const maxPriorityFeePerGas = shouldUsePriorityFees
74+
? getValues(MAX_PRIORITY_FEE_PER_GAS)
75+
: undefined;
76+
77+
console.log('customFees', shouldUsePriorityFees, maxFeePerGas, maxPriorityFeePerGas);
78+
6779
const feePerUnitError = errors.feePerUnit;
6880
const feeLimitError = errors.feeLimit;
6981

@@ -160,7 +172,7 @@ export const CustomFee = <TFieldValues extends FormState>({
160172
>
161173
<Translation id="TR_CUSTOM_FEE_WARNING" />
162174
</Banner>
163-
<Grid gap={spacings.xs} columns={useFeeLimit && !isBelowLaptop ? 2 : 1}>
175+
<Grid gap={spacings.xs} columns={1}>
164176
{useFeeLimit ? (
165177
<NumberInput
166178
label={<Translation id="TR_GAS_LIMIT" />}
@@ -183,21 +195,57 @@ export const CustomFee = <TFieldValues extends FormState>({
183195
) : (
184196
<input type="hidden" {...register(FEE_LIMIT as FieldPath<TFieldValues>)} />
185197
)}
186-
<NumberInput
187-
label={useFeeLimit ? <Translation id="TR_GAS_PRICE" /> : undefined}
188-
locale={locale}
189-
control={control}
190-
inputState={getInputState(feePerUnitError)}
191-
innerAddon={
192-
<Text variant="tertiary" typographyStyle="label">
193-
{feeUnits}
194-
</Text>
195-
}
196-
name={FEE_PER_UNIT}
197-
data-testid={FEE_PER_UNIT}
198-
rules={feeRules}
199-
bottomText={feePerUnitError?.message || null}
200-
/>
198+
199+
{shouldUsePriorityFees ? (
200+
<>
201+
<NumberInput
202+
label={<Translation id="TR_MAX_PRIORITY_FEE_PER_GAS" />}
203+
locale={locale}
204+
control={control}
205+
inputState={getInputState(feePerUnitError)}
206+
innerAddon={
207+
<Text variant="tertiary" typographyStyle="label">
208+
{feeUnits}
209+
</Text>
210+
}
211+
name={MAX_PRIORITY_FEE_PER_GAS}
212+
data-testid={MAX_PRIORITY_FEE_PER_GAS}
213+
rules={feeRules}
214+
bottomText={feePerUnitError?.message || null}
215+
/>
216+
<NumberInput
217+
label={<Translation id="TR_MAX_FEE_PER_GAS" />}
218+
locale={locale}
219+
control={control}
220+
inputState={getInputState(feePerUnitError)}
221+
innerAddon={
222+
<Text variant="tertiary" typographyStyle="label">
223+
{feeUnits}
224+
</Text>
225+
}
226+
name={MAX_FEE_PER_GAS}
227+
data-testid={MAX_FEE_PER_GAS}
228+
rules={feeRules}
229+
bottomText={feePerUnitError?.message || null}
230+
/>
231+
</>
232+
) : (
233+
<NumberInput
234+
label={useFeeLimit ? <Translation id="TR_GAS_PRICE" /> : undefined}
235+
locale={locale}
236+
control={control}
237+
inputState={getInputState(feePerUnitError)}
238+
innerAddon={
239+
<Text variant="tertiary" typographyStyle="label">
240+
{feeUnits}
241+
</Text>
242+
}
243+
name={FEE_PER_UNIT}
244+
data-testid={FEE_PER_UNIT}
245+
rules={feeRules}
246+
bottomText={feePerUnitError?.message || null}
247+
/>
248+
)}
201249
</Grid>
202250
{feeDifferenceWarning && <Note>{feeDifferenceWarning}</Note>}
203251
</Column>

0 commit comments

Comments
 (0)