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

feat: add error screen for RBF modal when TX is confirmed #16893

Merged
merged 1 commit into from
Feb 10, 2025
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 @@ -11,7 +11,7 @@ import {
SelectedAccountLoaded,
WalletAccountTransactionWithRequiredRbfParams,
} from '@suite-common/wallet-types';
import { Banner, Button, Column } from '@trezor/components';
import { Banner, Column, NewModal } from '@trezor/components';
import { PrecomposeResultFinal } from '@trezor/connect';
import { spacings } from '@trezor/theme';

Expand Down Expand Up @@ -81,9 +81,9 @@ export const CancelTransactionModal = ({
heading={<Translation id="TR_TRANSACTION_DETAILS" />}
bottomContent={
isTxConfirmed ? (
<Button variant="tertiary" onClick={onCancel}>
<NewModal.Button variant="tertiary" onClick={onCancel}>
<Translation id="TR_CLOSE_WINDOW" />
</Button>
</NewModal.Button>
) : (
<>
<CancelTransactionButton account={selectedAccount.account} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { selectTransactionConfirmations } from '@suite-common/wallet-core';
import {
ChainedTransactions,
SelectedAccountLoaded,
WalletAccountTransactionWithRequiredRbfParams,
} from '@suite-common/wallet-types';
import { NewModal } from '@trezor/components';

import { ChangeFee } from './ChangeFee';
import { ReplaceTxButton } from './ReplaceTxButton';
import { useSelector } from '../../../../../../../hooks/suite';
import { RbfContext, useRbf } from '../../../../../../../hooks/wallet/useRbfForm';
import { Translation } from '../../../../../Translation';
import { ReplaceByFeeFailedOriginalTxConfirmed } from '../ReplaceByFeeFailedOriginalTxConfirmed';
import { TxDetailModalBase } from '../TxDetailModalBase';

type BumpFeeModalProps = {
Expand All @@ -27,18 +31,37 @@ export const BumpFeeModal = ({
chainedTxs,
selectedAccount,
}: BumpFeeModalProps) => {
const { account } = selectedAccount;
const contextValues = useRbf({ rbfParams: tx.rbfParams, chainedTxs, selectedAccount });

const confirmations = useSelector(state =>
selectTransactionConfirmations(state, tx.txid, account.key),
);

const isTxConfirmed = confirmations > 0;

return (
<RbfContext.Provider value={contextValues}>
<TxDetailModalBase
tx={tx}
onCancel={onCancel}
heading={<Translation id="TR_TRANSACTION_DETAILS" />}
bottomContent={<ReplaceTxButton />}
bottomContent={
isTxConfirmed ? (
<NewModal.Button variant="tertiary" onClick={onCancel}>
<Translation id="TR_CLOSE_WINDOW" />
</NewModal.Button>
) : (
<ReplaceTxButton />
)
}
onBackClick={onBackClick}
>
<ChangeFee tx={tx} chainedTxs={chainedTxs} showChained={onShowChained} />
{isTxConfirmed ? (
<ReplaceByFeeFailedOriginalTxConfirmed type="replace-by-fee" />
) : (
<ChangeFee tx={tx} chainedTxs={chainedTxs} showChained={onShowChained} />
)}
</TxDetailModalBase>
</RbfContext.Provider>
);
Expand Down
Loading