Skip to content

Commit

Permalink
enhancement: displaying link to metamask page on install
Browse files Browse the repository at this point in the history
  • Loading branch information
dafuga committed Aug 22, 2024
1 parent 6e8d2f1 commit 757b571
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion packages/snap/src/index.ts
Original file line number Diff line number Diff line change
@@ -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`.
*
Expand All @@ -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);
}
};

0 comments on commit 757b571

Please sign in to comment.