Skip to content

Commit

Permalink
feat: migrate to new keyring-api version (0.2.x) (#64)
Browse files Browse the repository at this point in the history
* feat: migrate snap to API 0.2.2

* chore: run `yarn dedupe`

* chore: remove old comment

* chore: use sync flow by default

* chore: update UI and `personal_sign` to match new API
  • Loading branch information
danroc authored Sep 12, 2023
1 parent 2807968 commit 89e2444
Show file tree
Hide file tree
Showing 9 changed files with 254 additions and 301 deletions.
2 changes: 1 addition & 1 deletion packages/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"dependencies": {
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@metamask/keyring-api": "^0.1.3",
"@metamask/keyring-api": "^0.2.3",
"@metamask/providers": "^11.0.0",
"@mui/icons-material": "^5.14.0",
"@mui/material": "^5.14.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/site/src/components/Account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const Account = ({ account }: { account: KeyringAccount }) => {
return (
<AccountContainer>
<AccountTitleContainer>
<AccountTitle>{account.name}</AccountTitle>
<AccountTitle>{account.address}</AccountTitle>
<AccountTitleIconContainer>
{isCollapsed ? (
<ExpandMoreIcon
Expand Down Expand Up @@ -52,7 +52,7 @@ export const Account = ({ account }: { account: KeyringAccount }) => {
<AccountRow>
<AccountRowTitle>Account Supported Methods</AccountRowTitle>
<ul style={{ padding: '0px 0px 0px 16px' }}>
{account.supportedMethods.map((method, methodIndex) => (
{account.methods.map((method, methodIndex) => (
<AccountRowValue
key={`account-${account.id}-method-${methodIndex}`}
>
Expand Down
4 changes: 2 additions & 2 deletions packages/site/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const Index = () => {
// );

const sendCreateAccount = async () => {
const newAccount = await client.createAccount(accountName as string);
const newAccount = await client.createAccount();
const accounts = await client.listAccounts();
setSnapState({
...snapState,
Expand All @@ -97,7 +97,7 @@ const Index = () => {
};

const importAccount = async () => {
const newAccount = await client.createAccount(accountName as string, {
const newAccount = await client.createAccount({
privateKey: privateKey as string,
});
const accounts = await client.listAccounts();
Expand Down
6 changes: 3 additions & 3 deletions packages/snap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
"@ethereumjs/tx": "^4.1.2",
"@ethereumjs/util": "^8.0.5",
"@metamask/eth-sig-util": "^5.0.2",
"@metamask/keyring-api": "^0.1.3",
"@metamask/snaps-types": "^0.35.2-flask.1",
"@metamask/snaps-ui": "^0.35.2-flask.1",
"@metamask/keyring-api": "^0.2.3",
"@metamask/snaps-types": "^0.38.2-flask.1",
"@metamask/snaps-ui": "^0.37.4-flask.1",
"@metamask/utils": "^5.0.2",
"browserify": "^17.0.0",
"buffer": "^6.0.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "git+https://github.com/MetaMask/snap-simple-keyring.git"
},
"source": {
"shasum": "y1noKFUs5Et72OXnaaK+vDb7yHwqy7mz7Njahok/yD8=",
"shasum": "sWdabX/am+xwLsafCPEmovWw6Mc+4kJ2KJiYmkQwWk0=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
5 changes: 4 additions & 1 deletion packages/snap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from '@metamask/keyring-api';
import type { OnRpcRequestHandler } from '@metamask/snaps-types';
import { panel, heading, text } from '@metamask/snaps-ui';
import { Json } from '@metamask/utils';

import { SimpleKeyring } from './keyring';
import { InternalMethod, PERMISSIONS } from './permissions';
Expand Down Expand Up @@ -66,7 +67,9 @@ const permissionsHandler: OnRpcRequestHandler = async ({
* @param args.request - Request to execute.
* @returns The execution result.
*/
const keyringHandler: OnRpcRequestHandler = async ({ request }) => {
const keyringHandler: OnRpcRequestHandler<
Json[] | Record<string, Json>
> = async ({ request }) => {
if (!keyring) {
const keyringState = await getState();
if (!keyring) {
Expand Down
Loading

0 comments on commit 89e2444

Please sign in to comment.