From 1d4bda938f810ea02e6d867f4359af0749afa0b1 Mon Sep 17 00:00:00 2001 From: Kami Date: Fri, 23 Feb 2024 19:31:08 +0330 Subject: [PATCH] address issue Sayfer.SAY-01 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Display a warning similar to native metamask’s one on Sign message popup --- packages/snap/src/index.test.ts | 7 ++++++- packages/snap/src/rpc/signRaw.ts | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/snap/src/index.test.ts b/packages/snap/src/index.test.ts index 22ebf4d..5785c4c 100644 --- a/packages/snap/src/index.test.ts +++ b/packages/snap/src/index.test.ts @@ -172,8 +172,13 @@ describe('onRpcRequest', () => { panel([ heading(`A signature request is received from ${origin}`), divider(), - text('Data to sign:'), + text('Message to sign:'), panel([copyable(signRawParams.raw.data), divider()]), + row( + 'Warning:', + text(`**${'proceed only if you understand the message above!'}**`), + RowVariant.Warning, + ), ]) ); diff --git a/packages/snap/src/rpc/signRaw.ts b/packages/snap/src/rpc/signRaw.ts index 0e11311..48f3a40 100644 --- a/packages/snap/src/rpc/signRaw.ts +++ b/packages/snap/src/rpc/signRaw.ts @@ -1,5 +1,13 @@ /* eslint-disable jsdoc/require-jsdoc */ -import { copyable, divider, heading, panel, text } from '@metamask/snaps-sdk'; +import { + RowVariant, + copyable, + divider, + heading, + panel, + row, + text, +} from '@metamask/snaps-sdk'; import { SignerPayloadRaw, SignerResult } from '@polkadot/types/types'; import { isAscii, u8aToString, u8aUnwrapBytes } from '@polkadot/util'; import { getKeyPair } from '../util/getKeyPair'; @@ -12,8 +20,13 @@ const contentSignRaw = (origin: string, hexString: string) => { return panel([ heading(`A signature request is received from ${origin}`), divider(), - text('Data to sign:'), + text('Message to sign:'), panel([copyable(data), divider()]), + row( + 'Warning:', + text(`**${'proceed only if you understand the message above!'}**`), + RowVariant.Warning, + ), ]); };