Skip to content

Commit 63e4d56

Browse files
committed
[Issue-4365] feat: Update ui for new account ledger
1 parent 01c99eb commit 63e4d56

File tree

19 files changed

+164
-55
lines changed

19 files changed

+164
-55
lines changed

packages/extension-base/src/koni/background/handlers/Extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ export default class KoniExtension {
13641364
}
13651365

13661366
private async makeTransfer (inputData: RequestSubmitTransfer): Promise<SWTransactionResponse> {
1367-
const { chain, feeCustom, feeOption, from, to, tokenPayFeeSlug, tokenSlug, transferAll, transferBounceable, value } = inputData;
1367+
const { chain, feeCustom, feeOption, from, isSubstrateTransaction, to, tokenPayFeeSlug, tokenSlug, transferAll, transferBounceable, value } = inputData;
13681368
const transferTokenInfo = this.#koniState.chainService.getAssetBySlug(tokenSlug);
13691369
const errors = validateTransferRequest(transferTokenInfo, from, to, value, transferAll);
13701370
const warnings: TransactionWarning[] = [];
@@ -1386,7 +1386,7 @@ export default class KoniExtension {
13861386
const transferTokenAvailable = await this.getAddressTransferableBalance({ address: from, networkKey: chain, token: tokenSlug, extrinsicType });
13871387

13881388
try {
1389-
if (isEthereumAddress(from) && isEthereumAddress(to) && _isTokenTransferredByEvm(transferTokenInfo)) {
1389+
if (isEthereumAddress(from) && isEthereumAddress(to) && _isTokenTransferredByEvm(transferTokenInfo) && !isSubstrateTransaction) {
13901390
chainType = ChainType.EVM;
13911391
const txVal: string = transferAll ? transferTokenAvailable.value : (value || '0');
13921392
const evmApi = this.#koniState.getEvmApi(chain);

packages/extension-base/src/services/chain-service/utils/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ export function _isChainEvmCompatible (chainInfo: _ChainInfo) {
159159
return !!chainInfo.evmInfo;
160160
}
161161

162+
export function _isSubstrateEvmCompatibleChain (chainInfo: _ChainInfo) {
163+
return !!chainInfo.evmInfo && !!chainInfo.substrateInfo;
164+
}
165+
162166
export function _isChainBitcoinCompatible (chainInfo: _ChainInfo) {
163167
return !!chainInfo.bitcoinInfo;
164168
}

packages/extension-base/src/types/balance/transfer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ export interface RequestSubmitTransfer extends BaseRequestSign, TransactionFee {
3030
transferAll: boolean;
3131
value: string;
3232
transferBounceable?: boolean;
33+
isSubstrateTransaction?: boolean;
3334
}

packages/extension-koni-ui/src/Popup/Account/RestoreJson/AccountRestoreJsonItem.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
// Copyright 2019-2022 @subwallet/extension-koni-ui authors & contributors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { AccountProxyExtra, AccountProxyType } from '@subwallet/extension-base/types';
4+
import { AccountChainType, AccountProxyExtra, AccountProxyType } from '@subwallet/extension-base/types';
55
import { AccountChainTypeLogos, AccountProxyAvatar } from '@subwallet/extension-koni-ui/components';
66
import { useTranslation } from '@subwallet/extension-koni-ui/hooks';
77
import { Theme } from '@subwallet/extension-koni-ui/themes';
88
import { PhosphorIcon } from '@subwallet/extension-koni-ui/types';
9+
import { isSubstrateEcdsaAccountProxy } from '@subwallet/extension-koni-ui/utils';
910
import { Icon, Tooltip } from '@subwallet/react-ui';
1011
import CN from 'classnames';
1112
import { CheckCircle, Eye, GitCommit, Needle, QrCode, Question, Strategy, Swatches, Warning } from 'phosphor-react';
@@ -44,7 +45,14 @@ function Component (props: _AccountCardItem): React.ReactElement<_AccountCardIte
4445
onClick,
4546
showUnSelectedIcon } = props;
4647

47-
const { accountType, chainTypes, id: accountProxyId, name: accountName } = useMemo(() => accountProxy, [accountProxy]);
48+
const { accountType, id: accountProxyId, name: accountName } = useMemo(() => accountProxy, [accountProxy]);
49+
const chainTypes = useMemo(() => {
50+
if (isSubstrateEcdsaAccountProxy(accountProxy)) {
51+
return [AccountChainType.SUBSTRATE];
52+
}
53+
54+
return accountProxy.chainTypes;
55+
}, [accountProxy]);
4856
const { t } = useTranslation();
4957
const token = useContext<Theme>(ThemeContext as Context<Theme>).token;
5058
const disabledItem = useMemo(() => disabled || accountProxy.isExistAccount, [accountProxy.isExistAccount, disabled]);

packages/extension-koni-ui/src/Popup/Home/Earning/EarningPositionDetail/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import { NotificationType } from '@subwallet/extension-base/background/KoniTypes';
55
import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
6+
import { _isSubstrateEvmCompatibleChain } from '@subwallet/extension-base/services/chain-service/utils';
67
import { EarningRewardHistoryItem, SpecialYieldPoolInfo, SpecialYieldPositionInfo, YieldPoolInfo, YieldPoolType, YieldPositionInfo } from '@subwallet/extension-base/types';
78
import { AlertModal, Layout, PageWrapper } from '@subwallet/extension-koni-ui/components';
89
import { BN_TEN, BN_ZERO, DEFAULT_EARN_PARAMS, DEFAULT_UN_STAKE_PARAMS, EARN_TRANSACTION, UN_STAKE_TRANSACTION } from '@subwallet/extension-koni-ui/constants';
@@ -52,10 +53,14 @@ function Component ({ compound,
5253
return ALL_ACCOUNT_KEY;
5354
}
5455

55-
const accountAddress = currentAccountProxy?.accounts.find(({ chainType }) => {
56+
const accountAddress = currentAccountProxy?.accounts.find(({ chainType, isSubstrateECDSA }) => {
5657
if (chainInfoMap[poolInfo.chain]) {
5758
const chainInfo = chainInfoMap[poolInfo.chain];
5859

60+
if (isSubstrateECDSA) {
61+
return _isSubstrateEvmCompatibleChain(chainInfo);
62+
}
63+
5964
return isChainInfoAccordantAccountChainType(chainInfo, chainType);
6065
}
6166

packages/extension-koni-ui/src/Popup/Home/Tokens/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ const Component = (): React.ReactElement => {
6464
}, [currentAccountProxy]);
6565
const [currentTonAddress, setCurrentTonAddress] = useState(isAllAccount ? undefined : tonAddress);
6666

67-
console.log('accountProxies', accountProxies);
68-
6967
const handleScroll = useCallback((event: React.UIEvent<HTMLElement>) => {
7068
const topPosition = event.currentTarget.scrollTop;
7169

packages/extension-koni-ui/src/Popup/Transaction/variants/SendFund.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { CommonActionType, commonProcessReducer, DEFAULT_COMMON_PROCESS } from '
3030
import { RootState } from '@subwallet/extension-koni-ui/stores';
3131
import { AccountAddressItemType, ChainItemType, FormCallbacks, Theme, ThemeProps, TransferParams } from '@subwallet/extension-koni-ui/types';
3232
import { TokenSelectorItemType } from '@subwallet/extension-koni-ui/types/field';
33-
import { findAccountByAddress, formatBalance, getChainsByAccountAll, getChainsByAccountType, noop, SortableTokenItem, sortTokensByBalanceInSelector } from '@subwallet/extension-koni-ui/utils';
33+
import { findAccountByAddress, formatBalance, getChainsByAccountAll, getChainsByAccountType, isHasOnlySubstrateEcdsaAccountProxy, isSubstrateEcdsaAccountProxy, noop, SortableTokenItem, sortTokensByBalanceInSelector } from '@subwallet/extension-koni-ui/utils';
3434
import { Button, Form, Icon } from '@subwallet/react-ui';
3535
import { Rule } from '@subwallet/react-ui/es/form';
3636
import BigN from 'bignumber.js';
@@ -65,12 +65,13 @@ function getTokenItems (
6565
accountProxies: AccountProxy[],
6666
chainInfoMap: Record<string, _ChainInfo>,
6767
assetRegistry: Record<string, _ChainAsset>,
68-
tokenGroupSlug?: string // is ether a token slug or a multiChainAsset slug
68+
tokenGroupSlug?: string, // is ether a token slug or a multiChainAsset slug
69+
isSubstrateEcdsa?: boolean
6970
): TokenSelectorItemType[] {
7071
let allowedChains: string[];
7172

7273
if (!isAccountAll(accountProxy.id)) {
73-
allowedChains = getChainsByAccountType(chainInfoMap, accountProxy.chainTypes, accountProxy.specialChain);
74+
allowedChains = getChainsByAccountType(chainInfoMap, accountProxy.chainTypes, accountProxy.specialChain, isSubstrateEcdsa);
7475
} else {
7576
allowedChains = getChainsByAccountAll(accountProxy, accountProxies, chainInfoMap);
7677
}
@@ -176,6 +177,14 @@ const Component = ({ className = '', isAllAccount, targetAccountProxy }: Compone
176177
const { getCurrentConfirmation, renderConfirmationButtons } = useGetConfirmationByScreen('send-fund');
177178
const checkAction = usePreCheckAction(fromValue, true, detectTranslate('The account you are using is {{accountTitle}}, you cannot send assets with it'));
178179

180+
const isSubstrateEcdsa = useMemo(() => {
181+
if (!isAllAccount) {
182+
return isSubstrateEcdsaAccountProxy(targetAccountProxy);
183+
} else {
184+
return isHasOnlySubstrateEcdsaAccountProxy(accountProxies);
185+
}
186+
}, [accountProxies, isAllAccount, targetAccountProxy]);
187+
179188
const currentConfirmation = useMemo(() => {
180189
if (chainValue && destChainValue) {
181190
return getCurrentConfirmation([chainValue, destChainValue]);
@@ -320,7 +329,8 @@ const Component = ({ className = '', isAllAccount, targetAccountProxy }: Compone
320329
accountProxies,
321330
chainInfoMap,
322331
assetRegistry,
323-
sendFundSlug
332+
sendFundSlug,
333+
isSubstrateEcdsa
324334
);
325335

326336
const tokenBalanceMap = getAccountTokenBalance(
@@ -353,7 +363,7 @@ const Component = ({ className = '', isAllAccount, targetAccountProxy }: Compone
353363
sortTokensByBalanceInSelector(tokenItemsSorted, priorityTokens);
354364

355365
return tokenItemsSorted;
356-
}, [accountProxies, assetRegistry, chainInfoMap, chainStateMap, getAccountTokenBalance, priorityTokens, sendFundSlug, targetAccountProxy, targetAccountProxyIdForGetBalance]);
366+
}, [accountProxies, assetRegistry, chainInfoMap, chainStateMap, getAccountTokenBalance, isSubstrateEcdsa, priorityTokens, sendFundSlug, targetAccountProxy, targetAccountProxyIdForGetBalance]);
357367

358368
const isNotShowAccountSelector = !isAllAccount && accountAddressItems.length < 2;
359369

@@ -524,7 +534,8 @@ const Component = ({ className = '', isAllAccount, targetAccountProxy }: Compone
524534
transferBounceable: options.isTransferBounceable,
525535
feeOption: selectedTransactionFee?.feeOption,
526536
feeCustom: selectedTransactionFee?.feeCustom,
527-
tokenPayFeeSlug: currentTokenPayFee
537+
tokenPayFeeSlug: currentTokenPayFee,
538+
isSubstrateTransaction: isSubstrateEcdsa
528539
});
529540
} else {
530541
// Make cross chain transfer
@@ -544,7 +555,7 @@ const Component = ({ className = '', isAllAccount, targetAccountProxy }: Compone
544555
}
545556

546557
return sendPromise;
547-
}, [currentTokenPayFee, selectedTransactionFee?.feeOption, selectedTransactionFee?.feeCustom]);
558+
}, [selectedTransactionFee?.feeOption, selectedTransactionFee?.feeCustom, currentTokenPayFee, isSubstrateEcdsa]);
548559

549560
// todo: must refactor later, temporary solution to support SnowBridge
550561
const handleBridgeSpendingApproval = useCallback((values: TransferParams): Promise<SWTransactionResponse> => {

packages/extension-koni-ui/src/Popup/Transaction/variants/Swap/index.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { CommonActionType, commonProcessReducer, DEFAULT_COMMON_PROCESS } from '
2828
import { RootState } from '@subwallet/extension-koni-ui/stores';
2929
import { AccountAddressItemType, FormCallbacks, FormFieldData, SwapParams, ThemeProps, TokenBalanceItemType } from '@subwallet/extension-koni-ui/types';
3030
import { TokenSelectorItemType } from '@subwallet/extension-koni-ui/types/field';
31-
import { convertFieldToObject, findAccountByAddress, getChainsByAccountAll, isAccountAll, isChainInfoAccordantAccountChainType, isTokenCompatibleWithAccountChainTypes, SortableTokenItem, sortTokensByBalanceInSelector } from '@subwallet/extension-koni-ui/utils';
31+
import { convertFieldToObject, findAccountByAddress, getChainsByAccountAll, isAccountAll, isChainInfoAccordantAccountChainType, isSubstrateEcdsaAccountProxy, isTokenCompatibleWithAccountChainTypes, SortableTokenItem, sortTokensByBalanceInSelector } from '@subwallet/extension-koni-ui/utils';
3232
import { Button, Form, Icon, ModalContext } from '@subwallet/react-ui';
3333
import BigN from 'bignumber.js';
3434
import CN from 'classnames';
@@ -295,7 +295,9 @@ const Component = ({ targetAccountProxy }: ComponentProps) => {
295295
return false;
296296
}
297297

298-
if (!isTokenCompatibleWithAccountChainTypes(slug, targetAccountProxy.chainTypes, chainInfoMap)) {
298+
const isSubstrateECDSA = isSubstrateEcdsaAccountProxy(targetAccountProxy);
299+
300+
if (!isTokenCompatibleWithAccountChainTypes(slug, targetAccountProxy.chainTypes, chainInfoMap, isSubstrateECDSA)) {
299301
return false;
300302
}
301303

@@ -322,8 +324,10 @@ const Component = ({ targetAccountProxy }: ComponentProps) => {
322324
const destChainValue = _getAssetOriginChain(toAssetInfo);
323325

324326
const isSwitchable = useMemo(() => {
325-
return isTokenCompatibleWithAccountChainTypes(toTokenSlugValue, targetAccountProxy.chainTypes, chainInfoMap);
326-
}, [chainInfoMap, targetAccountProxy.chainTypes, toTokenSlugValue]);
327+
const isSubstrateECDSA = isSubstrateEcdsaAccountProxy(targetAccountProxy);
328+
329+
return isTokenCompatibleWithAccountChainTypes(toTokenSlugValue, targetAccountProxy.chainTypes, chainInfoMap, isSubstrateECDSA);
330+
}, [chainInfoMap, targetAccountProxy, toTokenSlugValue]);
327331

328332
// Unable to use useEffect due to infinity loop caused by conflict setCurrentSlippage and currentQuote
329333
const slippage = useMemo(() => {

packages/extension-koni-ui/src/assets/logo/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2019-2022 @subwallet/extension-koni-base authors & contributors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { SUBSTRATE_GENERIC_KEY, SUBSTRATE_MIGRATION_KEY } from '@subwallet/extension-koni-ui/constants';
4+
import { SUBSTRATE_ECDSA_KEY, SUBSTRATE_GENERIC_KEY, SUBSTRATE_MIGRATION_KEY } from '@subwallet/extension-koni-ui/constants';
55

66
export const DefaultLogosMap: Record<string, string> = {
77
subwallet: './images/projects/subwallet.png',
@@ -32,6 +32,7 @@ export const DefaultLogosMap: Record<string, string> = {
3232
currency_hkd: '/images/projects/CurrencyHKD.png',
3333
currency_vnd: '/images/projects/CurrencyVND.png',
3434
[SUBSTRATE_GENERIC_KEY]: './images/projects/polkadot.png',
35+
[SUBSTRATE_ECDSA_KEY]: './images/projects/polkadot.png',
3536
[SUBSTRATE_MIGRATION_KEY]: './images/projects/polkadot-migration.png',
3637
ton: './images/projects/ton.png',
3738
...Object.fromEntries( // Can use image from chain-list instead of local image

packages/extension-koni-ui/src/assets/subwallet/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { SwapProviderId } from '@subwallet/extension-base/types/swap';
55
import { DefaultLogosMap } from '@subwallet/extension-koni-ui/assets/logo';
6-
import { SUBSTRATE_GENERIC_KEY, SUBSTRATE_MIGRATION_KEY } from '@subwallet/extension-koni-ui/constants';
6+
import { SUBSTRATE_ECDSA_KEY, SUBSTRATE_GENERIC_KEY, SUBSTRATE_MIGRATION_KEY } from '@subwallet/extension-koni-ui/constants';
77

88
const SwLogosMap: Record<string, string> = {
99
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
@@ -25,6 +25,7 @@ const SwLogosMap: Record<string, string> = {
2525
hydradx_mainnet: DefaultLogosMap.hydradx,
2626
hydradx_testnet: DefaultLogosMap.hydradx,
2727
[SUBSTRATE_GENERIC_KEY]: DefaultLogosMap[SUBSTRATE_GENERIC_KEY],
28+
[SUBSTRATE_ECDSA_KEY]: DefaultLogosMap[SUBSTRATE_ECDSA_KEY],
2829
[SUBSTRATE_MIGRATION_KEY]: DefaultLogosMap[SUBSTRATE_MIGRATION_KEY],
2930
[SwapProviderId.POLKADOT_ASSET_HUB.toLowerCase()]: DefaultLogosMap.polkadot_assethub,
3031
[SwapProviderId.KUSAMA_ASSET_HUB.toLowerCase()]: DefaultLogosMap.kusama_assethub,

packages/extension-koni-ui/src/components/AccountProxy/AccountProxyItem.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
import { AccountChainType, AccountProxy } from '@subwallet/extension-base/types';
55
import { Theme } from '@subwallet/extension-koni-ui/themes';
66
import { ThemeProps } from '@subwallet/extension-koni-ui/types';
7+
import { isSubstrateEcdsaAccountProxy } from '@subwallet/extension-koni-ui/utils';
78
import { Icon } from '@subwallet/react-ui';
89
import CN from 'classnames';
910
import { CheckCircle } from 'phosphor-react';
10-
import React, { Context, useContext } from 'react';
11+
import React, { Context, useContext, useMemo } from 'react';
1112
import styled, { ThemeContext } from 'styled-components';
1213

1314
import AccountChainTypeLogos from './AccountChainTypeLogos';
@@ -29,7 +30,13 @@ type Props = ThemeProps & {
2930
function Component (props: Props): React.ReactElement<Props> {
3031
const { accountProxy, accountProxyName, chainTypes, className, isSelected, leftPartNode, onClick, renderRightPart, rightPartNode, showUnselectIcon } = props;
3132
const token = useContext<Theme>(ThemeContext as Context<Theme>).token;
33+
const accountChainTypes = useMemo(() => {
34+
if (isSubstrateEcdsaAccountProxy(accountProxy)) {
35+
return [AccountChainType.SUBSTRATE];
36+
}
3237

38+
return chainTypes;
39+
}, [accountProxy, chainTypes]);
3340
const checkedIconNode = ((showUnselectIcon || isSelected) && (
3441
<div className='__checked-icon-wrapper'>
3542
<Icon
@@ -44,7 +51,7 @@ function Component (props: Props): React.ReactElement<Props> {
4451
return (
4552
<div
4653
className={CN(className, {
47-
'-show-chain-type': !!chainTypes?.length
54+
'-show-chain-type': !!accountChainTypes?.length
4855
})}
4956
onClick={onClick}
5057
>
@@ -62,8 +69,8 @@ function Component (props: Props): React.ReactElement<Props> {
6269
<div className={'__account-name'}>
6370
{accountProxyName || accountProxy.name}
6471
</div>
65-
{!!chainTypes?.length && <AccountChainTypeLogos
66-
chainTypes={chainTypes}
72+
{!!accountChainTypes?.length && <AccountChainTypeLogos
73+
chainTypes={accountChainTypes}
6774
className={'__item-chain-type-logos'}
6875
/>}
6976
</div>

packages/extension-koni-ui/src/components/AccountProxy/AccountProxySelectorItem.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
// Copyright 2019-2022 @subwallet/extension-koni-ui authors & contributors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { AccountProxy, AccountProxyType } from '@subwallet/extension-base/types';
4+
import { AccountChainType, AccountProxy, AccountProxyType } from '@subwallet/extension-base/types';
55
import { useTranslation } from '@subwallet/extension-koni-ui/hooks';
66
import { Theme } from '@subwallet/extension-koni-ui/themes';
77
import { PhosphorIcon, ThemeProps } from '@subwallet/extension-koni-ui/types';
8+
import { isSubstrateEcdsaAccountProxy } from '@subwallet/extension-koni-ui/utils';
89
import { Button, Icon } from '@subwallet/react-ui';
910
import CN from 'classnames';
1011
import { CheckCircle, Copy, Eye, GitCommit, GitMerge, Needle, PencilSimpleLine, QrCode, Question, Strategy, Swatches } from 'phosphor-react';
1112
import { IconWeight } from 'phosphor-react/src/lib';
12-
import React, { Context, useContext } from 'react';
13+
import React, { Context, useContext, useMemo } from 'react';
1314
import styled, { ThemeContext } from 'styled-components';
1415

1516
import AccountChainTypeLogos from './AccountChainTypeLogos';
@@ -42,6 +43,13 @@ function Component (props: Props): React.ReactElement<Props> {
4243
showDerivedPath } = props;
4344

4445
const token = useContext<Theme>(ThemeContext as Context<Theme>).token;
46+
const chainTypes = useMemo(() => {
47+
if (isSubstrateEcdsaAccountProxy(accountProxy)) {
48+
return [AccountChainType.SUBSTRATE];
49+
}
50+
51+
return accountProxy.chainTypes;
52+
}, [accountProxy]);
4553

4654
const { t } = useTranslation();
4755

@@ -165,7 +173,7 @@ function Component (props: Props): React.ReactElement<Props> {
165173
)
166174
: (
167175
<AccountChainTypeLogos
168-
chainTypes={accountProxy.chainTypes}
176+
chainTypes={chainTypes}
169177
className={'__item-chain-type-logos'}
170178
/>
171179
)

packages/extension-koni-ui/src/components/Layout/parts/SelectAccount/ExportAllSelectItem.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
// Copyright 2019-2022 @subwallet/extension-koni-ui authors & contributors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { AccountProxy, AccountProxyType } from '@subwallet/extension-base/types';
4+
import { AccountChainType, AccountProxy, AccountProxyType } from '@subwallet/extension-base/types';
55
import { AccountChainTypeLogos, AccountProxyAvatar } from '@subwallet/extension-koni-ui/components';
66
import { Theme } from '@subwallet/extension-koni-ui/themes';
77
import { PhosphorIcon } from '@subwallet/extension-koni-ui/types';
8+
import { isSubstrateEcdsaAccountProxy } from '@subwallet/extension-koni-ui/utils';
89
import { Icon } from '@subwallet/react-ui';
910
import CN from 'classnames';
1011
import { CheckCircle, Eye, GitCommit, Needle, QrCode, Question, Strategy, Swatches } from 'phosphor-react';
@@ -37,7 +38,15 @@ function Component (props: _AccountCardItem): React.ReactElement<_AccountCardIte
3738
onClick,
3839
showUnSelectedIcon } = props;
3940

40-
const { accountType, chainTypes, id: accountProxyId, name: accountName } = useMemo(() => accountProxy, [accountProxy]);
41+
const { accountType, id: accountProxyId, name: accountName } = useMemo(() => accountProxy, [accountProxy]);
42+
43+
const chainTypes = useMemo(() => {
44+
if (isSubstrateEcdsaAccountProxy(accountProxy)) {
45+
return [AccountChainType.SUBSTRATE];
46+
}
47+
48+
return accountProxy.chainTypes;
49+
}, [accountProxy]);
4150

4251
const token = useContext<Theme>(ThemeContext as Context<Theme>).token;
4352
const _onSelect = useCallback(() => {

0 commit comments

Comments
 (0)