Skip to content

Commit

Permalink
feat: disable text message for cobo argus address (#1764)
Browse files Browse the repository at this point in the history
  • Loading branch information
vvvvvv1vvvvvv authored Sep 22, 2023
1 parent 71db517 commit 07dbdac
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/constant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1057,3 +1057,5 @@ export const SIGN_PERMISSION_OPTIONS = [
value: SIGN_PERMISSION_TYPES.TESTNET,
},
];

export const REJECT_SIGN_TEXT_KEYRINGS = [KEYRING_TYPE.CoboArgusKeyring];
8 changes: 8 additions & 0 deletions src/ui/views/Approval/components/SignText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
KEYRING_CLASS,
KEYRING_TYPE,
CHAINS,
REJECT_SIGN_TEXT_KEYRINGS,
} from 'consts';
import { hex2Text, useApproval, useCommonPopupView, useWallet } from 'ui/utils';
import { getKRCategoryByType } from '@/utils/transaction';
Expand Down Expand Up @@ -286,6 +287,13 @@ const SignText = ({ params }: { params: SignTextProps }) => {
signText: string,
sender: string
) => {
const currentAccount = await wallet.getCurrentAccount();
if (
currentAccount?.type &&
REJECT_SIGN_TEXT_KEYRINGS.includes(currentAccount.type)
) {
rejectApproval('This address can not sign text message', false, true);
}
const parsed = parseAction(textActionData, signText, sender);
setParsedActionData(parsed);
const ctx = formatSecurityEngineCtx({
Expand Down
7 changes: 7 additions & 0 deletions src/ui/views/Approval/components/SignTypedData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
KEYRING_CLASS,
KEYRING_TYPE,
CHAINS,
REJECT_SIGN_TEXT_KEYRINGS,
} from 'consts';
import IconGnosis from 'ui/assets/walletlogo/safe.svg';
import { useApproval, useCommonPopupView, useWallet } from 'ui/utils';
Expand Down Expand Up @@ -387,6 +388,12 @@ const SignTypedData = ({ params }: { params: SignTypedDataProps }) => {
const currentAccount = isGnosis
? account
: await wallet.getCurrentAccount();
if (
currentAccount?.type &&
REJECT_SIGN_TEXT_KEYRINGS.includes(currentAccount.type)
) {
rejectApproval('This address can not sign text message', false, true);
}
setIsLedger(currentAccount?.type === KEYRING_CLASS.HARDWARE.LEDGER);
setUseLedgerLive(await wallet.isUseLedgerLive());
};
Expand Down

0 comments on commit 07dbdac

Please sign in to comment.