Skip to content

Commit

Permalink
[fix][619] evm and cosmos warning, remove redundant character (#3593)
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
  • Loading branch information
TranTrungTien authored Jul 5, 2024
1 parent 28fc9f0 commit 8a7f53e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/app/core/constants/account.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ export const TABS_TITLE_ACCOUNT = [
{ label: TabsAccount.NftTxs, value: TabsAccountLink.NftTxs },
];

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."
16 changes: 11 additions & 5 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 { COSMOS_ACCOUNT_MESSAGE_TYPE, ACCOUNT_WALLET_COLOR, COSMOS_WARNING_MESSAGE, EVM_WARNING_MESSAGE } from '../../../core/constants/account.constant';
import { ACCOUNT_WALLET_COLOR, COSMOS_WARNING_MESSAGE, EVM_WARNING_MESSAGE, EVM_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 @@ -143,16 +143,22 @@ export class AccountDetailComponent implements OnInit, OnDestroy {
address: accountAddress,
};
this.userService.getAccountInfoOfAddress(payload).subscribe({
next: (data: { account?: {type?: string; sequence?: number; pubkey?: object}[] } = {}) => {
next: (data: { account?: {type?: any; sequence?: number; pubkey?: object}[] } = {}) => {
const { account } = data;

if(!account?.length) return;

const { type, sequence, pubkey = {} } = account[0] || {};

if (type !== COSMOS_ACCOUNT_MESSAGE_TYPE || !sequence) return;

if(!Object.keys(pubkey)?.length){
if (!type && !sequence) return;
console.log( type, sequence, pubkey);

if (type === EVM_ACCOUNT_MESSAGE_TYPE) {
this.accountType = 'evm';
this.tooltipCosmosText = COSMOS_WARNING_MESSAGE;
return;
}
if(!Object.keys(pubkey)?.length) {
this.accountType = 'evm';
this.tooltipCosmosText = COSMOS_WARNING_MESSAGE;
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</div>
<div *ngIf="ng.wallet?.cosmosAccount || ng.wallet?.evmAccount" class="connection-info mt-1">
<img [src]="'assets/icons/icons-svg/white/info.svg'" alt="warning">
<span>{{ng.wallet?.cosmosAccount ? "Aura Cosmos connected!." : ng.wallet?.evmAccount ? "Aura EVM connected!" :
<span>{{ng.wallet?.cosmosAccount ? "Aura Cosmos connected!" : ng.wallet?.evmAccount ? "Aura EVM connected!" :
""}}</span>
</div>
</ng-container>
Expand Down

0 comments on commit 8a7f53e

Please sign in to comment.