From 757b571b2da3963dab3c29dc97e8ed65b78e246b Mon Sep 17 00:00:00 2001 From: dafuga Date: Thu, 22 Aug 2024 15:34:49 -0700 Subject: [PATCH] enhancement: displaying link to metamask page on install --- packages/snap/src/index.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/snap/src/index.ts b/packages/snap/src/index.ts index 69f9a28..247ae76 100644 --- a/packages/snap/src/index.ts +++ b/packages/snap/src/index.ts @@ -1,11 +1,36 @@ import { type OnRpcRequestHandler, + type OnInstallHandler, MethodNotFoundError, + text, + panel, } from '@metamask/snaps-sdk'; import { getPublicKey, signTransaction } from './rpc'; import { AntelopeRequest, AntelopeSignatureRequest } from './types'; +const SNAP_NAME = 'Antelope MetaMask'; +const HELP_URL = 'https://unicove.com/eos/metamask'; + +/** + * Handle the installation of the snap. + * + * @returns A confirmation message to the user. + */ +export const onInstall: OnInstallHandler = async () => { + await snap.request({ + method: 'snap_dialog', + params: { + type: 'confirmation', + content: panel([ + text(`Welcome to the ${SNAP_NAME} Snap!`), + text('For help setting up an account, please visit:'), + text(HELP_URL), + ]), + }, + }); +}; + /** * Handle incoming JSON-RPC requests, sent through `wallet_invokeSnap`. * @@ -26,7 +51,6 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ request }) => { return String(await signTransaction(request as AntelopeSignatureRequest)); default: - // eslint-disable-next-line @typescript-eslint/no-throw-literal throw new MethodNotFoundError(request.method); } };