diff --git a/docs/content/docs/onboarding/project-structure.mdx b/docs/content/docs/onboarding/project-structure.mdx index 5de843209d..09fdca9af9 100644 --- a/docs/content/docs/onboarding/project-structure.mdx +++ b/docs/content/docs/onboarding/project-structure.mdx @@ -82,7 +82,7 @@ Domain's model **must**: - Export single object without `Model` suffix (`accounts`, not `accountsModel`). - Provide storage logic. - Create integrations with data sources. -- Be isolated, no other models in dependecies. +- Be isolated, no other models in dependencies. - Be testable. Model file should export single object with same name as entity. diff --git a/src/renderer/domains/network/accounts/service.ts b/src/renderer/domains/network/accounts/service.ts index 3ac186f65a..b276dc6782 100644 --- a/src/renderer/domains/network/accounts/service.ts +++ b/src/renderer/domains/network/accounts/service.ts @@ -22,7 +22,7 @@ function isUniversalAccount(account: Pick): account is Unive } function isAccountAvailableOnChain(account: Pick, chain: Chain) { - if (isCryptoMatch(account, chain) === false) { + if (!isCryptoMatch(account, chain)) { return false; } diff --git a/src/renderer/domains/network/accounts/types.ts b/src/renderer/domains/network/accounts/types.ts index 52d41b3278..2cbcc59041 100644 --- a/src/renderer/domains/network/accounts/types.ts +++ b/src/renderer/domains/network/accounts/types.ts @@ -21,7 +21,7 @@ export interface UniversalAccount { /** * @summary - * Account related to specific chain. This is most common case and such accounts + * Account related to specific chain. This is the most common case and such accounts * have "one to one" relations with other entities in the system. */ export interface ChainAccount { diff --git a/src/renderer/entities/wallet/ui/Cards/WalletCardLg.tsx b/src/renderer/entities/wallet/ui/Cards/WalletCardLg.tsx index 1c9c600b67..ca1915e74b 100644 --- a/src/renderer/entities/wallet/ui/Cards/WalletCardLg.tsx +++ b/src/renderer/entities/wallet/ui/Cards/WalletCardLg.tsx @@ -1,26 +1,24 @@ import { type PropsWithChildren, type ReactNode } from 'react'; import { type Wallet, WalletIconType } from '@/shared/core'; -import { cnTw } from '@/shared/lib/utils'; import { BodyText, FootnoteText } from '@/shared/ui'; import { walletUtils } from '../../lib/wallet-utils'; import { WalletIcon } from '../WalletIcon/WalletIcon'; type Props = PropsWithChildren<{ - className?: string; wallet: Wallet; description?: string | ReactNode; additionalInfo?: ReactNode; }>; -export const WalletCardLg = ({ wallet, description, additionalInfo, className, children }: Props) => { +export const WalletCardLg = ({ wallet, description, additionalInfo, children }: Props) => { const type = walletUtils.isFlexibleMultisig(wallet) && !wallet.activated ? WalletIconType.FLEXIBLE_MULTISIG_INACTIVE : wallet.type; return ( -
+
{additionalInfo} diff --git a/src/renderer/entities/wallet/ui/Cards/WalletCardMd.tsx b/src/renderer/entities/wallet/ui/Cards/WalletCardMd.tsx index b2d4c5d09b..62e401402b 100644 --- a/src/renderer/entities/wallet/ui/Cards/WalletCardMd.tsx +++ b/src/renderer/entities/wallet/ui/Cards/WalletCardMd.tsx @@ -5,24 +5,14 @@ import { cnTw, nonNullable, nullable } from '@/shared/lib/utils'; import { BodyText, FootnoteText } from '@/shared/ui'; import { WalletIcon } from '../WalletIcon/WalletIcon'; -type Props = { +type Props = PropsWithChildren<{ wallet: Wallet; description?: string | ReactNode; meta?: ReactNode; - prefix?: ReactNode; - hideIcon?: boolean; onClick?: () => void; -}; +}>; -export const WalletCardMd = ({ - wallet, - description, - meta, - prefix, - hideIcon, - children, - onClick, -}: PropsWithChildren) => { +export const WalletCardMd = ({ wallet, description, meta, children, onClick }: Props) => { const handleClick = (fn?: () => void) => { return (event: MouseEvent) => { if (!fn) return; @@ -46,9 +36,7 @@ export const WalletCardMd = ({ })} onClick={handleClick(onClick)} > - {prefix} - - {!hideIcon && } +
void; - onInfoClick?: () => void; -}; +}>; -export const WalletCardSm = ({ wallet, className, iconSize = 16, onClick, onInfoClick }: Props) => { +export const WalletCardSm = ({ wallet, onClick, children }: Props) => { const handleClick = (fn?: () => void) => { return (event: MouseEvent) => { if (!fn) return; @@ -28,11 +25,10 @@ export const WalletCardSm = ({ wallet, className, iconSize = 16, onClick, onInfo className={cnTw( 'group relative flex w-full items-center rounded transition-colors', 'focus-within:bg-action-background-hover hover:bg-action-background-hover', - className, )} > - {/* TODO: do the same as in WalletCardMd */} - + +
+ {children} +
); }; diff --git a/src/renderer/features/extension-wallet/components/WalletGroup.tsx b/src/renderer/features/extension-wallet/components/WalletGroup.tsx index c741d51755..848033626b 100644 --- a/src/renderer/features/extension-wallet/components/WalletGroup.tsx +++ b/src/renderer/features/extension-wallet/components/WalletGroup.tsx @@ -5,8 +5,8 @@ import { Slot, createSlot } from '@/shared/di'; import { useI18n } from '@/shared/i18n'; import { performSearch } from '@/shared/lib/utils'; import { Icon, type IconNames } from '@/shared/ui'; +import { WalletManagement } from '@/shared/ui-entities'; import { Accordion, Box, Label } from '@/shared/ui-kit'; -import { WalletCardMd } from '@/entities/wallet'; import { walletsFiatBalanceFeature } from '@/features/wallet-fiat-balance'; // TODO invert this dependency @@ -26,6 +26,7 @@ type Props = { export const WalletGroup = memo(({ wallets, icon, query, title, onSelect }: Props) => { const { t } = useI18n(); + const filteredWallets = performSearch({ query, records: wallets, @@ -48,24 +49,16 @@ export const WalletGroup = memo(({ wallets, icon, query, title, onSelect }: Prop {filteredWallets.map((wallet) => ( - } - prefix={ - wallet.isActive ? ( - - ) : ( -
- ) - } onClick={() => onSelect(wallet)} > - + ))} diff --git a/src/renderer/features/wallet-details/index.tsx b/src/renderer/features/wallet-details/index.tsx index a5e21a00c1..105d6175e9 100644 --- a/src/renderer/features/wallet-details/index.tsx +++ b/src/renderer/features/wallet-details/index.tsx @@ -10,13 +10,13 @@ import { walletActionsSlot as proxiedActionsSlot } from '@/features/wallet-proxi import { walletActionsSlot as walletConnectActionsSlot } from '@/features/wallet-wallet-connect'; import { walletActionsSlot as watchOnlyActionsSlot } from '@/features/wallet-watch-only'; -import { WalletDetails } from './ui/components/WalletDetails'; +import { WalletDetails } from './ui/components'; export { WalletDetails }; /** * The reason for the existence of this feature is WalletDetails component - * implementation. walletDetailsFeature should be absolete and details for each + * implementation. walletDetailsFeature should be obsolete and details for each * type of wallet should be coupled with wallet implementation. */ diff --git a/src/renderer/features/wallet-multisig/components/WalletGroup.tsx b/src/renderer/features/wallet-multisig/components/WalletGroup.tsx index 50b6d721f5..507feeada4 100644 --- a/src/renderer/features/wallet-multisig/components/WalletGroup.tsx +++ b/src/renderer/features/wallet-multisig/components/WalletGroup.tsx @@ -1,20 +1,13 @@ import { memo } from 'react'; import { type Wallet, WalletType } from '@/shared/core'; -import { Slot, createSlot } from '@/shared/di'; import { useI18n } from '@/shared/i18n'; import { performSearch } from '@/shared/lib/utils'; import { Icon } from '@/shared/ui'; import { Accordion, Box, Tooltip } from '@/shared/ui-kit'; -import { WalletCardMd, WalletIcon } from '@/entities/wallet'; -import { walletsFiatBalanceFeature } from '@/features/wallet-fiat-balance'; +import { WalletIcon } from '@/entities/wallet'; -// TODO invert this dependency -const { - views: { WalletFiatBalance }, -} = walletsFiatBalanceFeature; - -export const walletActionsSlot = createSlot<{ wallet: Wallet }>(); +import { WalletRow } from './WalletRow'; type Props = { title: string; @@ -26,6 +19,7 @@ type Props = { export const WalletGroup = memo(({ wallets, walletType, query, title, onSelect }: Props) => { const { t } = useI18n(); + const filteredWallets = performSearch({ query, records: wallets, @@ -57,24 +51,7 @@ export const WalletGroup = memo(({ wallets, walletType, query, title, onSelect } {filteredWallets.map(wallet => ( - - } - prefix={ - wallet.isActive ? ( - - ) : ( -
- ) - } - onClick={() => onSelect(wallet)} - > - - + ))} diff --git a/src/renderer/features/wallet-multisig/components/WalletRow.tsx b/src/renderer/features/wallet-multisig/components/WalletRow.tsx new file mode 100644 index 0000000000..eb943f9040 --- /dev/null +++ b/src/renderer/features/wallet-multisig/components/WalletRow.tsx @@ -0,0 +1,44 @@ +import { useStoreMap, useUnit } from 'effector-react'; + +import { type Wallet } from '@/shared/core'; +import { Slot, createSlot } from '@/shared/di'; +import { WalletManagement } from '@/shared/ui-entities'; +import { accounts as accountsDomainModel, accountsService } from '@/domains/network'; +import { ChainIcon } from '@/entities/chain'; +import { networkModel } from '@/entities/network'; +import { walletsFiatBalanceFeature } from '@/features/wallet-fiat-balance'; + +const { + views: { WalletFiatBalance }, +} = walletsFiatBalanceFeature; + +export const walletActionsSlot = createSlot<{ wallet: Wallet }>(); + +type Props = { + wallet: Wallet; + onSelect: (wallet: Wallet) => unknown; +}; +export const WalletRow = ({ wallet, onSelect }: Props) => { + const chains = useUnit(networkModel.$chains); + + const account = useStoreMap({ + store: accountsDomainModel.$list, + keys: [wallet.id], + fn: (accounts, [walletId]) => { + const match = accountsService.filterAccountsByWallet(accounts, walletId).at(0); + + return match && accountsService.isChainAccount(match) ? match : null; + }, + }); + + return ( + : null} + description={} + onClick={() => onSelect(wallet)} + > + + + ); +}; diff --git a/src/renderer/features/wallet-multisig/index.tsx b/src/renderer/features/wallet-multisig/index.tsx index 3332a72ced..a4d49aa929 100644 --- a/src/renderer/features/wallet-multisig/index.tsx +++ b/src/renderer/features/wallet-multisig/index.tsx @@ -8,7 +8,8 @@ import { accountsService } from '@/domains/network'; import { WalletIcon, accountUtils, walletUtils } from '@/entities/wallet'; import { walletGroupSlot, walletIconSlot } from '@/features/wallet-select'; -import { WalletGroup, walletActionsSlot } from './components/WalletGroup'; +import { WalletGroup } from './components/WalletGroup'; +import { walletActionsSlot } from './components/WalletRow'; import { walletsModel } from './model/wallets'; export { walletActionsSlot }; @@ -39,7 +40,7 @@ walletMultisigFeature.inject(walletGroupSlot, { render({ query, onSelect }) { const { t } = useI18n(); const regular = useUnit(walletsModel.$regularMultisig); - const flexible = useUnit(walletsModel.$flexibleMutisig); + const flexible = useUnit(walletsModel.$flexibleMultisig); return ( <> diff --git a/src/renderer/features/wallet-multisig/model/wallets.ts b/src/renderer/features/wallet-multisig/model/wallets.ts index b0200e4018..270b95c655 100644 --- a/src/renderer/features/wallet-multisig/model/wallets.ts +++ b/src/renderer/features/wallet-multisig/model/wallets.ts @@ -1,9 +1,9 @@ import { walletModel, walletUtils } from '@/entities/wallet'; export const $regularMultisig = walletModel.$wallets.map(list => list.filter(walletUtils.isRegularMultisig)); -export const $flexibleMutisig = walletModel.$wallets.map(list => list.filter(walletUtils.isFlexibleMultisig)); +export const $flexibleMultisig = walletModel.$wallets.map(list => list.filter(walletUtils.isFlexibleMultisig)); export const walletsModel = { $regularMultisig, - $flexibleMutisig, + $flexibleMultisig, }; diff --git a/src/renderer/features/wallet-polkadot-vault/components/WalletGroup.tsx b/src/renderer/features/wallet-polkadot-vault/components/WalletGroup.tsx index 9fd8f42f65..0c33aeaafb 100644 --- a/src/renderer/features/wallet-polkadot-vault/components/WalletGroup.tsx +++ b/src/renderer/features/wallet-polkadot-vault/components/WalletGroup.tsx @@ -3,9 +3,9 @@ import { memo } from 'react'; import { type Wallet, type WalletType } from '@/shared/core'; import { Slot, createSlot } from '@/shared/di'; import { performSearch } from '@/shared/lib/utils'; -import { Icon } from '@/shared/ui'; +import { WalletManagement } from '@/shared/ui-entities'; import { Accordion, Box } from '@/shared/ui-kit'; -import { WalletCardMd, WalletIcon } from '@/entities/wallet'; +import { WalletIcon } from '@/entities/wallet'; import { walletsFiatBalanceFeature } from '@/features/wallet-fiat-balance'; // TODO invert this dependency @@ -45,24 +45,16 @@ export const WalletGroup = memo(({ wallets, walletType, query, title, onSelect } {filteredWallets.map(wallet => ( - } - prefix={ - wallet.isActive ? ( - - ) : ( -
- ) - } onClick={() => onSelect(wallet)} > - + ))} diff --git a/src/renderer/features/wallet-proxied/components/WalletGroup.tsx b/src/renderer/features/wallet-proxied/components/WalletGroup.tsx index 05c9059e1b..4c3bac9558 100644 --- a/src/renderer/features/wallet-proxied/components/WalletGroup.tsx +++ b/src/renderer/features/wallet-proxied/components/WalletGroup.tsx @@ -1,31 +1,25 @@ import { memo } from 'react'; import { type Wallet, type WalletType } from '@/shared/core'; -import { Slot, createSlot } from '@/shared/di'; import { useI18n } from '@/shared/i18n'; import { performSearch } from '@/shared/lib/utils'; import { Icon } from '@/shared/ui'; import { Accordion, Box, Tooltip } from '@/shared/ui-kit'; -import { WalletCardMd, WalletIcon } from '@/entities/wallet'; -import { walletsFiatBalanceFeature } from '@/features/wallet-fiat-balance'; +import { WalletIcon } from '@/entities/wallet'; -// TODO invert this dependency -const { - views: { WalletFiatBalance }, -} = walletsFiatBalanceFeature; - -export const walletActionsSlot = createSlot<{ wallet: Wallet }>(); +import { WalletRow } from './WalletRow'; type Props = { title: string; walletType: WalletType; wallets: Wallet[]; query: string; - onSelect: (wallet: Wallet) => unknown; + onSelect: (wallet: Wallet) => void; }; export const WalletGroup = memo(({ wallets, walletType, query, title, onSelect }: Props) => { const { t } = useI18n(); + const filteredWallets = performSearch({ query, records: wallets, @@ -59,24 +53,7 @@ export const WalletGroup = memo(({ wallets, walletType, query, title, onSelect } {filteredWallets.map(wallet => ( - - } - prefix={ - wallet.isActive ? ( - - ) : ( -
- ) - } - onClick={() => onSelect(wallet)} - > - - + ))} diff --git a/src/renderer/features/wallet-proxied/components/WalletRow.tsx b/src/renderer/features/wallet-proxied/components/WalletRow.tsx new file mode 100644 index 0000000000..eb943f9040 --- /dev/null +++ b/src/renderer/features/wallet-proxied/components/WalletRow.tsx @@ -0,0 +1,44 @@ +import { useStoreMap, useUnit } from 'effector-react'; + +import { type Wallet } from '@/shared/core'; +import { Slot, createSlot } from '@/shared/di'; +import { WalletManagement } from '@/shared/ui-entities'; +import { accounts as accountsDomainModel, accountsService } from '@/domains/network'; +import { ChainIcon } from '@/entities/chain'; +import { networkModel } from '@/entities/network'; +import { walletsFiatBalanceFeature } from '@/features/wallet-fiat-balance'; + +const { + views: { WalletFiatBalance }, +} = walletsFiatBalanceFeature; + +export const walletActionsSlot = createSlot<{ wallet: Wallet }>(); + +type Props = { + wallet: Wallet; + onSelect: (wallet: Wallet) => unknown; +}; +export const WalletRow = ({ wallet, onSelect }: Props) => { + const chains = useUnit(networkModel.$chains); + + const account = useStoreMap({ + store: accountsDomainModel.$list, + keys: [wallet.id], + fn: (accounts, [walletId]) => { + const match = accountsService.filterAccountsByWallet(accounts, walletId).at(0); + + return match && accountsService.isChainAccount(match) ? match : null; + }, + }); + + return ( + : null} + description={} + onClick={() => onSelect(wallet)} + > + + + ); +}; diff --git a/src/renderer/features/wallet-proxied/index.tsx b/src/renderer/features/wallet-proxied/index.tsx index b4c4fd3493..5b226c30db 100644 --- a/src/renderer/features/wallet-proxied/index.tsx +++ b/src/renderer/features/wallet-proxied/index.tsx @@ -8,7 +8,8 @@ import { accountsService } from '@/domains/network'; import { WalletIcon, accountUtils, walletUtils } from '@/entities/wallet'; import { walletGroupSlot, walletIconSlot } from '@/features/wallet-select'; -import { WalletGroup, walletActionsSlot } from './components/WalletGroup'; +import { WalletGroup } from './components/WalletGroup'; +import { walletActionsSlot } from './components/WalletRow'; import { walletsModel } from './model/wallets'; export { walletActionsSlot }; diff --git a/src/renderer/features/wallet-wallet-connect/components/WalletGroup.tsx b/src/renderer/features/wallet-wallet-connect/components/WalletGroup.tsx index d3fcdd37af..a05c6c29a3 100644 --- a/src/renderer/features/wallet-wallet-connect/components/WalletGroup.tsx +++ b/src/renderer/features/wallet-wallet-connect/components/WalletGroup.tsx @@ -1,22 +1,11 @@ -import { useUnit } from 'effector-react'; import { memo } from 'react'; import { type Wallet, type WalletType } from '@/shared/core'; -import { Slot, createSlot } from '@/shared/di'; -import { cnTw, performSearch } from '@/shared/lib/utils'; -import { Icon } from '@/shared/ui'; +import { performSearch } from '@/shared/lib/utils'; import { Accordion, Box } from '@/shared/ui-kit'; -import { WalletCardMd, WalletIcon } from '@/entities/wallet'; -import { walletsFiatBalanceFeature } from '@/features/wallet-fiat-balance'; -import { walletConnectService } from '../lib/service'; -import { walletConnect } from '../model/connect'; +import { WalletIcon } from '@/entities/wallet'; -// TODO invert this dependency -const { - views: { WalletFiatBalance }, -} = walletsFiatBalanceFeature; - -export const walletActionsSlot = createSlot<{ wallet: Wallet }>(); +import { WalletRow } from './WalletRow'; type Props = { title: string; @@ -27,8 +16,6 @@ type Props = { }; export const WalletGroup = memo(({ wallets, walletType, query, title, onSelect }: Props) => { - const sessions = useUnit(walletConnect.$sessions); - const filteredWallets = performSearch({ query, records: wallets, @@ -49,36 +36,9 @@ export const WalletGroup = memo(({ wallets, walletType, query, title, onSelect } - {filteredWallets.map(wallet => { - const accounts = wallet.accounts.filter(walletConnectService.isWalletConnectAccount); - const connected = walletConnectService.areAccountsConnected(sessions, accounts); - - return ( - - } - prefix={ - wallet.isActive ? ( - - ) : ( -
- ) - } - meta={ - - } - onClick={() => onSelect(wallet)} - > - - - ); - })} + {filteredWallets.map(wallet => ( + + ))} diff --git a/src/renderer/features/wallet-wallet-connect/components/WalletRow.tsx b/src/renderer/features/wallet-wallet-connect/components/WalletRow.tsx new file mode 100644 index 0000000000..1fb7099dc1 --- /dev/null +++ b/src/renderer/features/wallet-wallet-connect/components/WalletRow.tsx @@ -0,0 +1,46 @@ +import { useStoreMap, useUnit } from 'effector-react'; + +import { type Wallet } from '@/shared/core'; +import { Slot, createSlot } from '@/shared/di'; +import { cnTw } from '@/shared/lib/utils'; +import { WalletManagement } from '@/shared/ui-entities'; +import { accounts as accountsDomainModel, accountsService } from '@/domains/network'; +import { walletsFiatBalanceFeature } from '@/features/wallet-fiat-balance'; +import { walletConnectService } from '../lib/service'; +import { walletConnect } from '../model/connect'; + +const { + views: { WalletFiatBalance }, +} = walletsFiatBalanceFeature; + +export const walletActionsSlot = createSlot<{ wallet: Wallet }>(); + +type Props = { + wallet: Wallet; + onSelect: (wallet: Wallet) => unknown; +}; +export const WalletRow = ({ wallet, onSelect }: Props) => { + const sessions = useUnit(walletConnect.$sessions); + + const connected = useStoreMap({ + store: accountsDomainModel.$list, + keys: [wallet.id, sessions], + fn: (accounts, [walletId, sessions]) => { + const wcAccounts = accounts.filter(walletConnectService.isWalletConnectAccount); + const walletAccounts = accountsService.filterAccountsByWallet(wcAccounts, walletId); + + return walletConnectService.areAccountsConnected(sessions, walletAccounts); + }, + }); + + return ( + } + description={} + onClick={() => onSelect(wallet)} + > + + + ); +}; diff --git a/src/renderer/features/wallet-wallet-connect/index.tsx b/src/renderer/features/wallet-wallet-connect/index.tsx index 3767e45dfb..834b3b36d3 100644 --- a/src/renderer/features/wallet-wallet-connect/index.tsx +++ b/src/renderer/features/wallet-wallet-connect/index.tsx @@ -50,7 +50,8 @@ walletWalletConnectFeature.inject(walletGroupSlot, { }); export { walletWalletConnectFeature } from './model/feature'; -export { WalletGroup, walletActionsSlot } from './components/WalletGroup'; +export { WalletGroup } from './components/WalletGroup'; +export { walletActionsSlot } from './components/WalletRow'; export { type InitConnectParams, type InitReconnectParams } from './lib/types'; export { DEFAULT_POLKADOT_METHODS } from './lib/constants'; export { walletConnectService } from './lib/service'; diff --git a/src/renderer/features/wallet-watch-only/components/WatchOnlyGroup.tsx b/src/renderer/features/wallet-watch-only/components/WatchOnlyGroup.tsx index d8c6698220..5eea35fef5 100644 --- a/src/renderer/features/wallet-watch-only/components/WatchOnlyGroup.tsx +++ b/src/renderer/features/wallet-watch-only/components/WatchOnlyGroup.tsx @@ -5,9 +5,9 @@ import { type Wallet, WalletType } from '@/shared/core'; import { Slot, createSlot } from '@/shared/di'; import { useI18n } from '@/shared/i18n'; import { performSearch } from '@/shared/lib/utils'; -import { Icon } from '@/shared/ui'; +import { WalletManagement } from '@/shared/ui-entities'; import { Accordion, Box } from '@/shared/ui-kit'; -import { WalletCardMd, WalletIcon } from '@/entities/wallet'; +import { WalletIcon } from '@/entities/wallet'; import { walletsFiatBalanceFeature } from '@/features/wallet-fiat-balance'; import { walletsModel } from '../model/wallets'; @@ -25,6 +25,7 @@ type Props = { export const WatchOnlyGroup = memo(({ query, onSelect }: Props) => { const { t } = useI18n(); + const wallets = useUnit(walletsModel.$wallets); const filteredWallets = performSearch({ @@ -48,24 +49,16 @@ export const WatchOnlyGroup = memo(({ query, onSelect }: Props) => { {filteredWallets.map(wallet => ( - } - prefix={ - wallet.isActive ? ( - - ) : ( -
- ) - } onClick={() => onSelect(wallet)} > - + ))} diff --git a/src/renderer/shared/core/types/wallet.ts b/src/renderer/shared/core/types/wallet.ts index 103aaa6b46..9358ddc4bf 100644 --- a/src/renderer/shared/core/types/wallet.ts +++ b/src/renderer/shared/core/types/wallet.ts @@ -53,7 +53,6 @@ export interface WatchOnlyWallet extends Wallet { accounts: VaultBaseAccount[]; } -// TODO: try to move signatories data out of account export interface MultisigWallet extends Wallet { type: WalletType.MULTISIG; accounts: MultisigAccount[]; diff --git a/src/renderer/shared/ui-entities/WalletManagement/WalletManagement.stories.tsx b/src/renderer/shared/ui-entities/WalletManagement/WalletManagement.stories.tsx new file mode 100644 index 0000000000..36dcf0f1be --- /dev/null +++ b/src/renderer/shared/ui-entities/WalletManagement/WalletManagement.stories.tsx @@ -0,0 +1,52 @@ +import { type Meta, type StoryObj } from '@storybook/react'; +import { noop } from 'lodash'; + +import { type MultisigWallet } from '@/shared/core'; +import { FootnoteText, IconButton } from '@/shared/ui'; +import { ChainIcon } from '@/entities/chain'; + +import { WalletManagement } from './WalletManagement'; + +const meta: Meta = { + title: 'Design System/entities/WalletManagement', + component: WalletManagement, + args: { + wallet: { + id: 1, + type: 'wallet_ms', + name: 'WalletManagement', + isActive: true, + accounts: [], + isHidden: false, + signingType: 'signing_ms', + } as MultisigWallet, + children: , + }, + parameters: { + layout: 'centered', + }, +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = {}; + +export const WithMeta: Story = { + args: { + meta: ( + + ), + }, +}; + +export const WithDescription: Story = { + args: { + meta: , + description: 1000 $, + }, +}; diff --git a/src/renderer/shared/ui-entities/WalletManagement/WalletManagement.tsx b/src/renderer/shared/ui-entities/WalletManagement/WalletManagement.tsx new file mode 100644 index 0000000000..7fa360191e --- /dev/null +++ b/src/renderer/shared/ui-entities/WalletManagement/WalletManagement.tsx @@ -0,0 +1,61 @@ +import { type PropsWithChildren, type ReactNode } from 'react'; + +import { type Wallet } from '@/shared/core'; +import { cnTw } from '@/shared/lib/utils'; +import { BodyText, FootnoteText, Icon } from '@/shared/ui'; + +type Props = { + wallet: Wallet; + description?: string | ReactNode; + meta?: ReactNode; + onClick: () => void; +}; + +export const WalletManagement = ({ wallet, description, meta, children, onClick }: PropsWithChildren) => { + return ( +
+ + +
+ {children} +
+
+ ); +}; diff --git a/src/renderer/shared/ui-entities/index.ts b/src/renderer/shared/ui-entities/index.ts index 31653124a0..d9be42989a 100644 --- a/src/renderer/shared/ui-entities/index.ts +++ b/src/renderer/shared/ui-entities/index.ts @@ -5,6 +5,7 @@ export { Account } from './Account/Account'; export { AssetIcon } from './AssetIcon/AssetIcon'; export { AccountSelectModal } from './AccountSelectModal/AccountSelectModal'; export { AccountExplorers } from './AccountExplorers/AccountExplorers'; +export { WalletManagement } from './WalletManagement/WalletManagement'; export { RootExplorers } from './RootExplorer/RootExplorers'; export { TransactionDetails } from './TransactionDetails/TransactionDetails'; export { RankedAccount } from './RankedAccount/RankedAccount';