Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refactoring of the TxDetailModal to split the BumpFee (rbf) flow #15977

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { spacings } from '@trezor/theme';

import { Translation, FiatValue, FormattedCryptoAmount } from 'src/components/suite';
import { useSelector } from 'src/hooks/suite';
import { useRbf, RbfContext, UseRbfProps } from 'src/hooks/wallet/useRbfForm';
import { useRbfContext, UseRbfProps } from 'src/hooks/wallet/useRbfForm';

import { RbfFees } from './RbfFees';
import { AffectedTransactions } from './AffectedTransactions';
Expand All @@ -21,53 +21,53 @@ interface ChangeFeeProps extends UseRbfProps {
}

const ChangeFeeLoaded = (props: ChangeFeeProps) => {
const contextValues = useRbf(props);
peter-sanderson marked this conversation as resolved.
Show resolved Hide resolved
const { tx, showChained, children } = props;
const { networkType } = contextValues.account;
const {
account: { networkType },
} = useRbfContext();
peter-sanderson marked this conversation as resolved.
Show resolved Hide resolved

const feeRate =
networkType === 'bitcoin' ? `${tx.rbfParams?.feeRate} ${getFeeUnits(networkType)}` : null;
const fee = formatNetworkAmount(tx.fee, tx.symbol);

return (
<RbfContext.Provider value={contextValues}>
<Card fillType="none">
<InfoItem
direction="row"
label={
<>
<Translation id="TR_CURRENT_FEE" />
&nbsp;({feeRate})
</>
}
typographyStyle="body"
>
<Row gap={spacings.md} alignItems="baseline">
<FormattedCryptoAmount
<Card fillType="none">
<InfoItem
direction="row"
label={
<>
<Translation id="TR_CURRENT_FEE" />
&nbsp;({feeRate})
</>
}
typographyStyle="body"
>
<Row gap={spacings.md} alignItems="baseline">
<FormattedCryptoAmount
disableHiddenPlaceholder
value={fee}
symbol={tx.symbol}
/>
<Text variant="tertiary" typographyStyle="label">
<FiatValue
disableHiddenPlaceholder
value={fee}
amount={fee}
symbol={tx.symbol}
showApproximationIndicator
/>
<Text variant="tertiary" typographyStyle="label">
<FiatValue
disableHiddenPlaceholder
amount={fee}
symbol={tx.symbol}
showApproximationIndicator
/>
</Text>
</Row>
</InfoItem>
</Text>
</Row>
</InfoItem>

<Divider />
<Divider />

<RbfFees />
<RbfFees />

<DecreasedOutputs />
<AffectedTransactions showChained={showChained} />
<DecreasedOutputs />
<AffectedTransactions showChained={showChained} />

{children}
</Card>
</RbfContext.Provider>
{children}
</Card>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
import { NewModal } from '@trezor/components';
import { SelectedAccountLoaded, RbfTransactionParams } from '@suite-common/wallet-types';

import { Translation } from 'src/components/suite';
import { useDevice } from 'src/hooks/suite';
import { useRbf } from 'src/hooks/wallet/useRbfForm';
import { useRbfContext } from 'src/hooks/wallet/useRbfForm';

type ReplaceTxButtonProps = {
rbfParams: RbfTransactionParams;
selectedAccount: SelectedAccountLoaded;
};

export const ReplaceTxButton = ({ rbfParams, selectedAccount }: ReplaceTxButtonProps) => {
export const ReplaceTxButton = () => {
const { device, isLocked } = useDevice();
const { isLoading, signTransaction, getValues, composedLevels } = useRbf({
peter-sanderson marked this conversation as resolved.
Show resolved Hide resolved
selectedAccount,
rbfParams,
});

const { isLoading, signTransaction, getValues, composedLevels } = useRbfContext();

const values = getValues();
const composedTx = composedLevels ? composedLevels[values.selectedFee || 'normal'] : undefined;
Expand Down
Loading
Loading