Skip to content

Commit 61ba6ee

Browse files
refactor(receive): make address cards self-contained and use shared copy action
1 parent 4a23117 commit 61ba6ee

53 files changed

Lines changed: 906 additions & 696 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/suite/src/views/wallet/receive/Receive.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useDevice, useRequestDeviceConnection } from '@suite/device';
1+
import { useDevice } from '@suite/device';
22
import { ReceiveContent } from '@suite/receive';
33
import { selectIsCoinjoinReceiveWarningHidden } from '@suite/settings';
44
import { selectSelectedDevice } from '@suite-common/device';
@@ -18,7 +18,6 @@ export const Receive = () => {
1818

1919
const { account } = selectedAccount;
2020
const { isLocked } = useDevice();
21-
const requestDeviceConnection = useRequestDeviceConnection();
2221

2322
if (account === undefined) {
2423
return null;
@@ -38,7 +37,6 @@ export const Receive = () => {
3837
account={account}
3938
locked={isLocked(true)}
4039
AmountComponent={FormattedCryptoAmount}
41-
requestDeviceConnection={requestDeviceConnection}
4240
/>
4341
</Column>
4442

suite-common/address/src/getFirstFreshAddress.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { type Account, type ReceiveInfo } from '@suite-common/wallet-types';
1+
import { type Account, type AccountAddress, type ReceiveInfo } from '@suite-common/wallet-types';
22
import { comparePath } from '@trezor/crypto-utils';
33

4-
type AccountAddress = NonNullable<Account['addresses']>['used'][number];
5-
64
const isPathLowerThanAnyUsedPath = (path: string, usedPaths: string[]) =>
75
usedPaths.some(usedPath => comparePath(path, usedPath) < 0);
86

suite-common/address/src/getReceiveAddressHistory.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import { type Account, type ReceiveInfo } from '@suite-common/wallet-types';
1+
import { type Account, type AccountAddress, type ReceiveInfo } from '@suite-common/wallet-types';
22
import { comparePath } from '@trezor/crypto-utils';
33

44
import { getFirstFreshAddress, getFreshAddresses } from './getFirstFreshAddress';
55

6-
type AccountAddress = NonNullable<Account['addresses']>['used'][number];
7-
86
type CurrentFreshAddress = {
97
path: string;
108
address: string;

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import { type RequestEnableTorResponse } from '@suite-common/suite-config';
22
import { type NetworkSymbol } from '@suite-common/wallet-config';
3-
import {
4-
type Account,
5-
type AddressType,
6-
type EvmSelectedFee,
7-
} from '@suite-common/wallet-types';
3+
import { type Account, type AddressType, type EvmSelectedFee } from '@suite-common/wallet-types';
84
import { type UI_REQUEST } from '@trezor/connect';
95
import { type Deferred } from '@trezor/utils';
106

suite-common/wallet-types/src/account.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ export type Account = AccountBase &
210210
export type FailedAccount = Extract<Account, { failed: true }>;
211211
export type SuccessfulAccount = Extract<Account, { failed?: false }>;
212212

213+
export type AccountAddress = NonNullable<Account['addresses']>['used'][number];
214+
213215
export type WalletParams =
214216
| NonNullable<{
215217
symbol: NetworkSymbol;

suite/address/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
"@suite-common/suite-constants": "workspace:*",
2020
"@suite-common/suite-sync": "workspace:*",
2121
"@suite-common/toast-notifications": "workspace:*",
22+
"@suite-common/wallet-config": "workspace:*",
2223
"@suite-common/wallet-core": "workspace:*",
2324
"@suite-common/wallet-types": "workspace:*",
2425
"@suite/account": "workspace:*",
26+
"@suite/intl": "workspace:*",
27+
"@suite/labeling": "workspace:*",
2528
"@suite/metadata": "workspace:*",
2629
"@suite/modal": "workspace:*",
2730
"@trezor/components": "workspace:*",
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { Address } from '@suite/address';
21
import { useTranslation } from '@suite/intl';
32
import { Labeling } from '@suite/labeling';
43
import { type NetworkSymbol } from '@suite-common/wallet-config';
54
import { type AccountDescriptor, createAccountKey } from '@suite-common/wallet-types';
65
import { type StaticSessionId } from '@trezor/device-utils';
76

7+
import { Address } from './Address';
8+
89
type AddressLabelingProps = {
910
accountDescriptor: AccountDescriptor;
1011
networkSymbol: NetworkSymbol;

suite/address/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './Address';
2+
export * from './AddressLabeling';
23
export * from './copyAddressActions';
34
export * from './labels/selectAddressLabel';
45
export * from './labels/selectAddressLabelsForAccount';

suite/address/tsconfig.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@
2121
{
2222
"path": "../../suite-common/toast-notifications"
2323
},
24+
{
25+
"path": "../../suite-common/wallet-config"
26+
},
2427
{
2528
"path": "../../suite-common/wallet-core"
2629
},
2730
{
2831
"path": "../../suite-common/wallet-types"
2932
},
3033
{ "path": "../account" },
34+
{ "path": "../intl" },
35+
{ "path": "../labeling" },
3136
{ "path": "../metadata" },
3237
{ "path": "../modal" },
3338
{ "path": "../../packages/components" },

suite/analytics/src/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ export enum EventType {
5858
PromoDesktop = 'promo/desktop',
5959
PromoMobile = 'promo/mobile',
6060
PromoReferralButton = 'promo/referral-button',
61+
ReceiveAddAddress = 'receive/add-address',
62+
ReceiveCopyAddress = 'receive/copy-address',
63+
ReceiveOpenNonFreshAddress = 'receive/open-non-fresh-address',
64+
ReceiveShareAddress = 'receive/share-address',
65+
ReceiveStartVerification = 'receive/start-verification',
6166
// eslint-disable-next-line local-rules/analytics-event-name
6267
RemoveToken = 'remove-token',
6368
// eslint-disable-next-line local-rules/analytics-event-name

0 commit comments

Comments
 (0)