Skip to content

Commit

Permalink
[update][619] update logic check wallet type (#3613)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
TranTrungTien authored Jul 10, 2024
1 parent b6063a2 commit 087fa95
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/app/core/constants/account.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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."

Expand Down
25 changes: 17 additions & 8 deletions src/app/pages/account/account-detail/account-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 087fa95

Please sign in to comment.