Skip to content

Commit 868cea4

Browse files
feat: UI facelift of the Affected transactions in the RBF flow
1 parent 769cb04 commit 868cea4

File tree

14 files changed

+102
-139
lines changed

14 files changed

+102
-139
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { Banner, Button, Column } from '@trezor/components';
2+
import { spacings } from '@trezor/theme';
3+
import { ChainedTransactions } from '@suite-common/wallet-types';
4+
5+
import { Translation } from 'src/components/suite';
6+
7+
import { AffectedTransactionItem } from './AffectedTransactionItem';
8+
9+
type AffectedTransactionsProps = {
10+
chainedTxs?: ChainedTransactions;
11+
showChained: () => void;
12+
};
13+
14+
export const AffectedTransactions = ({ chainedTxs, showChained }: AffectedTransactionsProps) => {
15+
if (chainedTxs === undefined) {
16+
return null;
17+
}
18+
19+
return (
20+
<Column gap={spacings.md}>
21+
<Banner
22+
variant="warning"
23+
rightContent={
24+
<Button
25+
variant="warning"
26+
onClick={showChained}
27+
icon="caretRight"
28+
iconAlignment="right"
29+
>
30+
<Translation id="TR_SEE_DETAILS" />
31+
</Button>
32+
}
33+
>
34+
<Translation id="TR_AFFECTED_TXS" />
35+
</Banner>
36+
<Column alignItems="center">
37+
{chainedTxs.own.map(tx => (
38+
<AffectedTransactionItem key={tx.txid} tx={tx} isAccountOwned />
39+
))}
40+
{chainedTxs.others.map(tx => (
41+
<AffectedTransactionItem key={tx.txid} tx={tx} />
42+
))}
43+
</Column>
44+
</Column>
45+
);
46+
};

packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/TxDetailModal/ChainedTxs.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { AccountType, Network } from '@suite-common/wallet-config';
77
import { TrezorLink, Translation } from 'src/components/suite';
88
import { TransactionItem } from 'src/components/wallet/TransactionItem/TransactionItem';
99

10-
import { AffectedTransactionItem } from './ChangeFee/AffectedTransactionItem';
10+
import { AffectedTransactionItem } from './AffectedTransactions/AffectedTransactionItem';
1111

1212
const Wrapper = styled.div`
1313
text-align: left;

packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/TxDetailModal/ChangeFee/AffectedTransactions.tsx

-51
This file was deleted.

packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/TxDetailModal/ChangeFee/ChangeFee.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { useSelector } from 'src/hooks/suite';
1010
import { useRbfContext, UseRbfProps } from 'src/hooks/wallet/useRbfForm';
1111

1212
import { RbfFees } from './RbfFees';
13-
import { AffectedTransactions } from './AffectedTransactions';
13+
import { AffectedTransactions } from '../AffectedTransactions/AffectedTransactions';
1414
import { DecreasedOutputs } from './DecreasedOutputs';
1515

1616
/* children are only for test purposes, this prop is not available in regular build */
@@ -23,7 +23,9 @@ interface ChangeFeeProps extends UseRbfProps {
2323
const ChangeFeeLoaded = (props: ChangeFeeProps) => {
2424
const { tx, showChained, children } = props;
2525
const {
26+
2627
account: { networkType },
28+
chainedTxs,
2729
} = useRbfContext();
2830

2931
const feeRate =
@@ -64,7 +66,8 @@ const ChangeFeeLoaded = (props: ChangeFeeProps) => {
6466
<RbfFees />
6567

6668
<DecreasedOutputs />
67-
<AffectedTransactions showChained={showChained} />
69+
70+
<AffectedTransactions chainedTxs={chainedTxs} showChained={showChained} />
6871

6972
{children}
7073
</Card>

packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/TxDetailModal/ChangeFee/DecreasedOutputs.tsx

+5-8
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,14 @@ import { ReactNode } from 'react';
33
import styled from 'styled-components';
44
import { AnimatePresence, motion } from 'framer-motion';
55

6-
import { Icon, variables, Radio, motionAnimation } from '@trezor/components';
6+
import { Icon, variables, Radio, motionAnimation, Banner, Column } from '@trezor/components';
77
import { formatNetworkAmount } from '@suite-common/wallet-utils';
88
import { spacings } from '@trezor/theme';
99

1010
import { FormattedCryptoAmount, HiddenPlaceholder } from 'src/components/suite';
1111
import { Translation, TranslationKey } from 'src/components/suite/Translation';
1212
import { useRbfContext } from 'src/hooks/wallet/useRbfForm';
1313

14-
import { GreyCard } from './GreyCard';
15-
import { WarnHeader } from './WarnHeader';
16-
1714
const OutputsWrapper = styled.div`
1815
display: flex;
1916
flex-direction: column;
@@ -111,10 +108,10 @@ export const DecreasedOutputs = () => {
111108
return (
112109
<AnimatePresence initial>
113110
<motion.div {...motionAnimation.expand}>
114-
<GreyCard>
115-
<WarnHeader data-testid="@send/decreased-outputs">
111+
<Column>
112+
<Banner variant="warning" data-testid="@send/decreased-outputs">
116113
<Translation id={decreaseWarning} />
117-
</WarnHeader>
114+
</Banner>
118115
<OutputsWrapper>
119116
{formValues.outputs.flatMap((o, i) => {
120117
if (typeof o.address !== 'string') return null;
@@ -164,7 +161,7 @@ export const DecreasedOutputs = () => {
164161
);
165162
})}
166163
</OutputsWrapper>
167-
</GreyCard>
164+
</Column>
168165
</motion.div>
169166
</AnimatePresence>
170167
);

packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/TxDetailModal/ChangeFee/GreyCard.tsx

-20
This file was deleted.

packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/TxDetailModal/ChangeFee/WarnHeader.tsx

-37
This file was deleted.

packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/TxDetailModal/Detail/AdvancedTxDetails/AmountDetails.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ import { Timestamp, TokenAddress } from '@suite-common/wallet-types';
2020
import { useSelector } from 'src/hooks/suite';
2121
import { selectLocalCurrency } from 'src/reducers/wallet/settingsReducer';
2222
import { WalletAccountTransaction } from 'src/types/wallet';
23-
import { Translation, FormattedCryptoAmount, FiatValue, FormattedDate } from 'src/components/suite';
23+
import {
24+
Translation,
25+
FormattedCryptoAmount,
26+
FiatValue,
27+
FormattedDate,
28+
} from 'src/components/suite';
2429
import { AmountComponent } from 'src/components/wallet/AmountComponent';
2530

2631
type AmountDetailsProps = {

packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/TxDetailModal/TxDetailModalBase.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const TxDetailModalBase = ({
5555
bottomContent={bottomContent}
5656
onBackClick={onBackClick}
5757
>
58-
<Column gap={spacings.lg}>
58+
<Column gap={spacings.md}>
5959
<BasicTxDetails
6060
explorerUrl={blockchain.explorer.tx}
6161
explorerUrlQueryString={blockchain.explorer.queryString}

packages/suite/src/components/wallet/TransactionItem/TransactionItem.tsx

+18-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const StyledFeeRow = styled(FeeRow)<{ $noInputsOutputs?: boolean }>`
6262
const DEFAULT_LIMIT = 3;
6363

6464
type OpenModalParams = {
65-
flow: 'detail' | 'bump-fee';
65+
flow: 'detail' | 'bump-fee' | 'cancel-transaction';
6666
};
6767

6868
interface TransactionItemProps {
@@ -155,6 +155,8 @@ export const TransactionItem = memo(
155155
const isExpandable = allOutputs.length - DEFAULT_LIMIT > 0;
156156
const toExpand = allOutputs.length - DEFAULT_LIMIT - limit;
157157

158+
const isTxCancellable = transaction.type !== 'self';
159+
158160
const openTxDetailsModal = ({ flow }: OpenModalParams) => {
159161
if (isActionDisabled) return; // open explorer
160162
dispatch(
@@ -184,6 +186,17 @@ export const TransactionItem = memo(
184186
</Button>
185187
);
186188

189+
const CancelTransactionButton = ({ isDisabled }: { isDisabled: boolean }) => (
190+
<Button
191+
variant="tertiary"
192+
icon="x"
193+
onClick={() => openTxDetailsModal({ flow: 'cancel-transaction' })}
194+
isDisabled={isDisabled}
195+
>
196+
<Translation id="TR_CANCEL_TX" />
197+
</Button>
198+
);
199+
187200
const DisabledBumpFeeButtonWithTooltip = () => (
188201
<Tooltip
189202
content={
@@ -477,12 +490,16 @@ export const TransactionItem = memo(
477490
flex="1"
478491
alignItems="flex-start"
479492
margin={{ bottom: spacings.xxs }}
493+
gap={spacings.sm}
480494
>
481495
{disableBumpFee ? (
482496
<DisabledBumpFeeButtonWithTooltip />
483497
) : (
484498
<BumpFeeButton isDisabled={false} />
485499
)}
500+
{isTxCancellable && (
501+
<CancelTransactionButton isDisabled={false} />
502+
)}
486503
</Row>
487504
)}
488505
</Content>

packages/urls/src/urls.ts

+2
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ export const HELP_CENTER_FIRMWARE_REVISION_CHECK: Url =
115115
'https://trezor.io/learn/a/trezor-firmware-revision-check';
116116
export const HELP_CENTER_REPLACE_BY_FEE: Url =
117117
'https://trezor.io/learn/a/replace-by-fee-rbf-ethereum';
118+
export const HELP_CENTER_CANCEL_TRANSACTION: Url =
119+
'https://trezor.io/support/a/can-i-cancel-or-reverse-a-transaction';
118120

119121
export const INVITY_URL: Url = 'https://invity.io/';
120122
export const INVITY_SCHEDULE_OF_FEES: Url = 'https://blog.invity.io/schedule-of-fees';

suite-common/suite-types/src/modal.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export type UserContextPayload =
5151
| {
5252
type: 'transaction-detail';
5353
tx: WalletAccountTransaction;
54-
flow: 'detail' | 'bump-fee';
54+
flow: 'detail' | 'bump-fee' | 'cancel-transaction';
5555
}
5656
| {
5757
type: 'review-transaction';

suite-common/wallet-core/src/index.ts

+17-16
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
11
export * from './accounts/accountsActions';
22
export * from './accounts/accountsConstants';
3+
export * from './accounts/accountsMiddleware';
34
export * from './accounts/accountsReducer';
45
export * from './accounts/accountsThunks';
5-
export * from './accounts/accountsMiddleware';
6-
export * from './transactions/transactionsActions';
7-
export * from './transactions/transactionsReducer';
8-
export * from './transactions/transactionsThunks';
96
export * from './blockchain/blockchainActions';
7+
export * from './blockchain/blockchainMiddleware';
108
export * from './blockchain/blockchainReducer';
119
export * from './blockchain/blockchainSelectors';
1210
export * from './blockchain/blockchainThunks';
13-
export * from './blockchain/blockchainMiddleware';
14-
export * from './fiat-rates/fiatRatesReducer';
15-
export * from './fiat-rates/fiatRatesSelectors';
16-
export * from './fiat-rates/fiatRatesThunks';
17-
export * from './fiat-rates/fiatRatesMiddleware';
18-
export * from './fiat-rates/fiatRatesTypes';
11+
export * from './device/deviceActions';
12+
export * from './device/deviceConstants';
13+
export * from './device/deviceReducer';
14+
export * from './device/deviceThunks';
1915
export * from './discovery/discoveryActions';
2016
export * from './discovery/discoveryReducer';
2117
export * from './discovery/discoveryThunks';
2218
export * from './fees/feesReducer';
19+
export * from './fiat-rates/fiatRatesMiddleware';
20+
export * from './fiat-rates/fiatRatesReducer';
21+
export * from './fiat-rates/fiatRatesSelectors';
22+
export * from './fiat-rates/fiatRatesThunks';
23+
export * from './fiat-rates/fiatRatesTypes';
24+
export * from './send/composeCancelTransactionThunk';
2325
export * from './send/sendFormActions';
2426
export * from './send/sendFormReducer';
2527
export * from './send/sendFormThunks';
2628
export * from './send/sendFormTypes';
27-
export * from './device/deviceActions';
28-
export * from './device/deviceThunks';
29-
export * from './device/deviceReducer';
30-
export * from './device/deviceConstants';
3129
export * from './stake/stakeActions';
30+
export * from './stake/stakeConstants';
31+
export * from './stake/stakeMiddleware';
3232
export * from './stake/stakeReducer';
3333
export * from './stake/stakeSelectors';
34-
export * from './stake/stakeMiddleware';
3534
export * from './stake/stakeThunks';
3635
export * from './stake/stakeTypes';
37-
export * from './stake/stakeConstants';
36+
export * from './transactions/transactionsActions';
37+
export * from './transactions/transactionsReducer';
38+
export * from './transactions/transactionsThunks';

0 commit comments

Comments
 (0)