Skip to content

Commit

Permalink
fix(suite): fee hack moved from UI down to the place where we load it
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-sanderson committed Apr 30, 2024
1 parent 0a04077 commit eaf6b63
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
13 changes: 6 additions & 7 deletions packages/suite/src/components/wallet/Fees/Fees.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import { CustomFee } from './CustomFee';
import { FeeDetails } from './FeeDetails';
import { AnimatePresence, motion } from 'framer-motion';
import { TranslationKey } from '@suite-common/intl-types';

const Container = styled.div`
overflow: hidden; /* prevent scrollbar when custom fee is opened */
Expand Down Expand Up @@ -83,7 +84,7 @@ const HelperTextWrapper = styled(Paragraph)`
font-size: ${variables.FONT_SIZE.SMALL};
`;

const FEE_LEVELS_TRANSLATIONS = {
const FEE_LEVELS_TRANSLATIONS: Record<FeeLevel['label'], TranslationKey> = {
custom: 'FEE_LEVEL_CUSTOM',
high: 'FEE_LEVEL_HIGH',
normal: 'FEE_LEVEL_NORMAL',
Expand All @@ -92,12 +93,10 @@ const FEE_LEVELS_TRANSLATIONS = {
} as const;

const buildFeeOptions = (levels: FeeLevel[]) =>
levels
.filter(level => level.label !== 'low') // hack to hide "low" fee option
.map(({ label }) => ({
label: <Translation id={FEE_LEVELS_TRANSLATIONS[label]} />,
value: label,
}));
levels.map(({ label }) => ({
label: <Translation id={FEE_LEVELS_TRANSLATIONS[label]} />,
value: label,
}));

export interface FeesProps<TFieldValues extends FormState> {
account: Account;
Expand Down
2 changes: 1 addition & 1 deletion packages/suite/src/hooks/wallet/useCoinmarketSellForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const useCoinmarketSellForm = ({
const { shouldSendInSats } = useBitcoinAmountUnit(symbol);

const coinFees = fees[symbol];
const levels = getFeeLevels(networkType, coinFees).filter(level => level.label !== 'low');
const levels = getFeeLevels(networkType, coinFees);
const feeInfo = { ...coinFees, levels };
const symbolForFiat = mapTestnetSymbol(symbol);
const localCurrencyOption = { value: localCurrency, label: localCurrency.toUpperCase() };
Expand Down
19 changes: 15 additions & 4 deletions suite-common/wallet-core/src/blockchain/blockchainThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,20 @@ export const preloadFeeInfoThunk = createThunk(
const partial: Partial<NetworksFees> = {};
networks.forEach((network, index) => {
const result = levels[index];

if (result.success) {
const { payload } = result;
partial[network.symbol] = {
blockHeight: 0,
...payload,
levels: sortLevels(payload.levels).map(l => ({
...l,
label: l.label || 'normal',
levels: sortLevels(
payload.levels
// hack to hide "low" fee option
// (we do not want to change the connect API as it is a potentially breaking change)
.filter(level => level.label !== 'low'),
).map(level => ({
...level,
label: level.label || 'normal',
})),
};
}
Expand Down Expand Up @@ -130,7 +136,12 @@ export const updateFeeInfoThunk = createThunk(
if (result.success) {
newFeeInfo = {
...result.payload,
levels: sortLevels(result.payload.levels),
levels: sortLevels(
result.payload.levels
// hack to hide "low" fee option
// (we do not want to change the connect API as it is a potentially breaking change)
.filter(level => level.label !== 'low'),
),
};
}
}
Expand Down

0 comments on commit eaf6b63

Please sign in to comment.