Skip to content

Commit

Permalink
Use Snaps SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrtenz committed Nov 22, 2023
1 parent 94fa31a commit c0ee060
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 202 deletions.
7 changes: 3 additions & 4 deletions packages/snap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
"test": "jest"
},
"dependencies": {
"@metamask/snaps-types": "^3.0.1",
"@metamask/snaps-ui": "^3.0.1",
"@metamask/snaps-sdk": "^1.2.0",
"buffer": "^6.0.3"
},
"devDependencies": {
Expand All @@ -38,8 +37,8 @@
"@metamask/eslint-config-jest": "^12.0.0",
"@metamask/eslint-config-nodejs": "^12.0.0",
"@metamask/eslint-config-typescript": "^12.0.0",
"@metamask/snaps-cli": "^3.0.1",
"@metamask/snaps-jest": "^3.0.0",
"@metamask/snaps-cli": "^3.0.3",
"@metamask/snaps-jest": "^4.0.1",
"@typescript-eslint/eslint-plugin": "^5.42.1",
"@typescript-eslint/parser": "^5.42.1",
"eslint": "^8.45.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from '@jest/globals';
import { installSnap } from '@metamask/snaps-jest';
import { panel, text } from '@metamask/snaps-ui';
import { panel, text } from '@metamask/snaps-sdk';

describe('onRpcRequest', () => {
describe('hello', () => {
Expand Down
9 changes: 6 additions & 3 deletions packages/snap/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { OnRpcRequestHandler } from '@metamask/snaps-types';
import { panel, text } from '@metamask/snaps-ui';
import type { OnRpcRequestHandler } from '@metamask/snaps-sdk';
import { panel, text } from '@metamask/snaps-sdk';

/**
* Handle incoming JSON-RPC requests, sent through `wallet_invokeSnap`.
Expand All @@ -11,7 +11,10 @@ import { panel, text } from '@metamask/snaps-ui';
* @returns The result of `snap_dialog`.
* @throws If the request method is not valid for this snap.
*/
export const onRpcRequest: OnRpcRequestHandler = ({ origin, request }) => {
export const onRpcRequest: OnRpcRequestHandler = async ({
origin,
request,
}) => {
switch (request.method) {
case 'hello':
return snap.request({
Expand Down
Loading

0 comments on commit c0ee060

Please sign in to comment.