From 087fa95fd31166f79624a7ed918220b3861300e5 Mon Sep 17 00:00:00 2001 From: TranTrungTien <71311738+TranTrungTien@users.noreply.github.com> Date: Wed, 10 Jul 2024 15:20:33 +0700 Subject: [PATCH] [update][619] update logic check wallet type (#3613) * feat: warning for cosmos and evm address is incompatible * feat: warning for compatible between cosmos address and evm address * remove trash code * format code * update query and logic for warning address * update nested if else * update * resolved conflict * update: query cosmos and evm * update: new query account info * update: rename variable * update: new UI for warning address * fix: remove redundant character * fix: evm and cosmos warning * update: logic check address type * update: logic check receive token firstly * update: hard code base account * update: undefined wallet type if type or sequence empty * update logic warning --- src/app/core/constants/account.constant.ts | 3 ++- .../account-detail.component.ts | 25 +++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/app/core/constants/account.constant.ts b/src/app/core/constants/account.constant.ts index 2f90d8c5f..3ca437f26 100644 --- a/src/app/core/constants/account.constant.ts +++ b/src/app/core/constants/account.constant.ts @@ -32,7 +32,8 @@ export const TABS_TITLE_ACCOUNT = [ { label: TabsAccount.NftTxs, value: TabsAccountLink.NftTxs }, ]; -export const EVM_ACCOUNT_MESSAGE_TYPE = "'/ethermint.types.v1.EthAccount'"; +export const COSMOS_ACCOUNT_MESSAGE_TYPE = "/cosmos.auth.v1beta1.BaseAccount"; +export const EVM_ACCOUNT_MESSAGE_TYPE = "/ethermint.types.v1.EthAccount"; export const COSMOS_WARNING_MESSAGE = "An account created by a EVM wallet (such as Metamask, Rabby, etc.) cannot be used to sign Cosmos transactions." export const EVM_WARNING_MESSAGE = "An account created by a Cosmos wallet (such as Keplr, Leap,...) cannot be used to sign EVM transactions." diff --git a/src/app/pages/account/account-detail/account-detail.component.ts b/src/app/pages/account/account-detail/account-detail.component.ts index c9909494c..314e58c07 100644 --- a/src/app/pages/account/account-detail/account-detail.component.ts +++ b/src/app/pages/account/account-detail/account-detail.component.ts @@ -16,7 +16,7 @@ import { WalletService } from 'src/app/core/services/wallet.service'; import { transferAddress } from 'src/app/core/utils/common/address-converter'; import local from 'src/app/core/utils/storage/local'; import { EnvironmentService } from '../../../../app/core/data-services/environment.service'; -import { ACCOUNT_WALLET_COLOR, COSMOS_WARNING_MESSAGE, EVM_WARNING_MESSAGE, EVM_ACCOUNT_MESSAGE_TYPE, BASE_ACCOUNT_ADDRESS } from '../../../core/constants/account.constant'; +import { ACCOUNT_WALLET_COLOR, COSMOS_WARNING_MESSAGE, EVM_WARNING_MESSAGE, EVM_ACCOUNT_MESSAGE_TYPE, BASE_ACCOUNT_ADDRESS, COSMOS_ACCOUNT_MESSAGE_TYPE } from '../../../core/constants/account.constant'; import { ACCOUNT_WALLET_COLOR_ENUM, ENameTag, WalletAcount } from '../../../core/constants/account.enum'; import { DATE_TIME_WITH_MILLISECOND, STORAGE_KEYS } from '../../../core/constants/common.constant'; import { AccountService } from '../../../core/services/account.service'; @@ -156,19 +156,28 @@ export class AccountDetailComponent implements OnInit, OnDestroy { if(!account?.length) return; const { type, sequence, pubkey = {} } = account[0] || {}; - - if (!type && !sequence) return; if (type === EVM_ACCOUNT_MESSAGE_TYPE) { this.accountType = 'evm'; this.tooltipCosmosText = COSMOS_WARNING_MESSAGE; return; } - if(!pubkey || !Object.keys(pubkey)?.length) { - this.accountType = 'evm'; - this.tooltipCosmosText = COSMOS_WARNING_MESSAGE; - return; - }else { + + if (type === COSMOS_ACCOUNT_MESSAGE_TYPE) { + if (!sequence) return; + + if(!pubkey || !Object.keys(pubkey)?.length) { + this.accountType = 'evm'; + this.tooltipCosmosText = COSMOS_WARNING_MESSAGE; + return; + }else { + this.accountType = 'cosmos'; + this.tooltipEvmText = EVM_WARNING_MESSAGE; + return; + } + } + + if (type) { this.accountType = 'cosmos'; this.tooltipEvmText = EVM_WARNING_MESSAGE; return;