Skip to content

Commit

Permalink
fix: fix metamask updates
Browse files Browse the repository at this point in the history
- pin rollup-plugin to 3.0.0
- remove mm cli and just use sirv to serve the snap
- fix all the new types and ui coming from the sdk package
  • Loading branch information
hugomrdias committed Mar 4, 2024
1 parent e3ba5bd commit 1d6ddb0
Show file tree
Hide file tree
Showing 26 changed files with 3,494 additions and 2,739 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/adapter-react.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ on:
- master
paths:
- 'packages/adapter-react/**'
- '.github/workflows/adapter-react.yml'
- 'pnpm-lock.yaml'
- .github/workflows/adapter-react.yml
- pnpm-lock.yaml
pull_request:
paths:
- 'packages/adapter-react/**'
- '.github/workflows/adapter-react.yml'
- 'pnpm-lock.yaml'
- .github/workflows/adapter-react.yml
- pnpm-lock.yaml
jobs:
test:
timeout-minutes: 60
Expand All @@ -29,7 +29,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'
cache: pnpm
- run: pnpm install
- run: pnpm -r --filter filsnap-adapter-react run lint
- run: pnpm -r --filter filsnap-adapter-react exec depcheck
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/adapter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ on:
- master
paths:
- 'packages/adapter/**'
- '.github/workflows/adapter.yml'
- 'pnpm-lock.yaml'
- .github/workflows/adapter.yml
- pnpm-lock.yaml
pull_request:
paths:
- 'packages/adapter/**'
- '.github/workflows/adapter.yml'
- 'pnpm-lock.yaml'
- .github/workflows/adapter.yml
- pnpm-lock.yaml
jobs:
test:
timeout-minutes: 60
Expand All @@ -30,7 +30,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'
cache: pnpm
- run: pnpm install
- run: pnpm --filter filsnap-adapter exec playwright install --with-deps chromium
- run: pnpm -r --filter filsnap-adapter run lint
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/snap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ on:
- master
paths:
- 'packages/snap/**'
- '.github/workflows/snap.yml'
- 'pnpm-lock.yaml'
- .github/workflows/snap.yml
- pnpm-lock.yaml
pull_request:
paths:
- 'packages/snap/**'
- '.github/workflows/snap.yml'
- 'pnpm-lock.yaml'
- .github/workflows/snap.yml
- pnpm-lock.yaml
jobs:
test:
timeout-minutes: 60
Expand All @@ -30,7 +30,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'
cache: pnpm
- run: pnpm install
- run: pnpm --filter filsnap exec playwright install --with-deps chromium
- run: pnpm -r --filter filsnap run lint
Expand Down
24 changes: 12 additions & 12 deletions examples/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,30 @@
}
},
"dependencies": {
"@acab/reset.css": "^0.7.0",
"@preact/signals": "^1.2.1",
"clsx": "^2.0.0",
"dns-over-http-resolver": "^2.1.2",
"@acab/reset.css": "^0.8.0",
"@preact/signals": "^1.2.2",
"clsx": "^2.1.0",
"dns-over-http-resolver": "^3.0.2",
"filsnap-adapter": "*",
"filsnap-adapter-react": "*",
"iso-base": "^2.0.1",
"iso-filecoin": "^3.0.1",
"preact": "^10.17.1",
"react-hook-form": "^7.46.2",
"iso-filecoin": "^4.0.3",
"preact": "^10.19.6",
"react-hook-form": "^7.51.0",
"viem": "^1.16.2",
"wagmi": "^1.4.2",
"water.css": "^2.1.1"
},
"devDependencies": {
"@babel/core": "^7.22.20",
"@preact/preset-vite": "^2.5.0",
"@types/node": "^20.8.4",
"@babel/core": "^7.24.0",
"@preact/preset-vite": "^2.8.1",
"@types/node": "^20.11.24",
"hd-scripts": "^9.0.6",
"react": "^18.2.0",
"tiny-git-rev-sync": "^0.1.0",
"typescript": "5.2.2",
"typescript": "5.3.3",
"vite": "^4.4.11",
"wireit": "^0.14.0"
"wireit": "^0.14.4"
},
"eslintConfig": {
"extends": [
Expand Down
12 changes: 6 additions & 6 deletions examples/fil-forwarder-viem/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@
"dependencies": {
"filsnap-adapter": "*",
"iso-base": "^2.0.1",
"iso-filecoin": "^3.0.1",
"prettier": "3.0.3",
"iso-filecoin": "^4.0.3",
"prettier": "3.2.5",
"viem": "^1.16.2"
},
"devDependencies": {
"@babel/core": "^7.22.20",
"@types/node": "^20.8.4",
"@babel/core": "^7.24.0",
"@types/node": "^20.11.24",
"hd-scripts": "^9.0.6",
"typescript": "5.2.2",
"typescript": "5.3.3",
"vite": "^4.4.11",
"wireit": "^0.14.0"
"wireit": "^0.14.4"
},
"eslintConfig": {
"extends": [
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
"docs": "typedoc --out docs --plugin typedoc-plugin-missing-exports --plugin typedoc-plugin-zod"
},
"devDependencies": {
"depcheck": "^1.4.6",
"depcheck": "^1.4.7",
"hd-scripts": "^9.0.6",
"lint-staged": "^14.0.1",
"prettier": "3.0.3",
"simple-git-hooks": "^2.9.0",
"typedoc": "^0.25.2",
"typedoc-plugin-missing-exports": "^2.1.0",
"typedoc-plugin-zod": "^1.1.0",
"typescript": "5.2.2",
"wireit": "^0.14.0"
"lint-staged": "^15.2.2",
"prettier": "3.2.5",
"simple-git-hooks": "^2.10.0",
"typedoc": "^0.25.10",
"typedoc-plugin-missing-exports": "^2.2.0",
"typedoc-plugin-zod": "^1.1.2",
"typescript": "5.3.3",
"wireit": "^0.14.4"
},
"simple-git-hooks": {
"pre-commit": "npx lint-staged"
Expand Down
18 changes: 9 additions & 9 deletions packages/adapter-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@
"filsnap-adapter": "workspace:^"
},
"devDependencies": {
"@testing-library/react": "^14.0.0",
"@types/mocha": "^10.0.1",
"@types/node": "^20.8.4",
"@types/react": "^18.2.27",
"@types/react-dom": "^18.2.12",
"@testing-library/react": "^14.2.1",
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.24",
"@types/react": "^18.2.61",
"@types/react-dom": "^18.2.19",
"assert": "^2.1.0",
"mocha": "^10.2.0",
"playwright-test": "^12.3.4",
"preact": "^10.17.1",
"mocha": "^10.3.0",
"playwright-test": "^14.1.1",
"preact": "^10.19.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "5.2.2"
"typescript": "5.3.3"
},
"publishConfig": {
"provenance": true
Expand Down
10 changes: 5 additions & 5 deletions packages/adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
},
"dependencies": {
"filsnap": "workspace:^",
"iso-filecoin": "^3.0.1"
"iso-filecoin": "^4.0.3"
},
"devDependencies": {
"@playwright/test": "^1.38.0",
"@types/node": "^20.8.4",
"metamask-testing-tools": "^1.1.10",
"typescript": "5.2.2"
"@playwright/test": "^1.42.1",
"@types/node": "^20.11.24",
"metamask-testing-tools": "^1.2.1",
"typescript": "5.3.3"
},
"publishConfig": {
"provenance": true
Expand Down
24 changes: 13 additions & 11 deletions packages/snap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
]
},
"serve": {
"command": "mm-snap serve",
"command": "sirv --port 8081",
"dependencies": [
{
"script": "build",
Expand All @@ -77,26 +77,28 @@
},
"dependencies": {
"@metamask/key-tree": "^9.0.0",
"@metamask/snaps-ui": "^3.0.0",
"@metamask/snaps-sdk": "^3.0.1",
"iso-base": "^2.0.1",
"iso-filecoin": "^3.0.1",
"iso-filecoin": "^4.0.3",
"merge-options": "^3.0.4",
"sirv-cli": "^2.0.2",
"viem": "^1.16.2",
"zod": "^3.22.4"
},
"devDependencies": {
"@metamask/snaps-cli": "^3.0.0",
"@metamask/snaps-rollup-plugin": "^3.0.0",
"@metamask/snaps-types": "^3.0.0",
"@playwright/test": "^1.38.0",
"@rollup/plugin-commonjs": "^25.0.5",
"@playwright/test": "^1.42.1",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-sucrase": "^5.0.2",
"@rollup/plugin-terser": "^0.4.4",
"metamask-testing-tools": "^1.1.10",
"playwright-test": "^12.3.4",
"rollup": "^4.0.2",
"typescript": "5.2.2"
"@rollup/plugin-typescript": "^11.1.6",
"metamask-testing-tools": "^1.2.1",
"playwright-test": "^14.1.1",
"rollup": "^4.12.0",
"type-fest": "^4.11.0",
"typescript": "5.3.3"
},
"publishConfig": {
"provenance": true
Expand Down
4 changes: 2 additions & 2 deletions packages/snap/playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default defineConfig({
browserName: 'chromium',
},
webServer: {
command: 'pnpm run build && pnpm exec mm-snap serve',
url: 'http://localhost:8081',
command: 'pnpm run build && pnpm exec sirv --port 8081',
url: 'http://localhost:8081/dist/snap.js',
},
})
2 changes: 0 additions & 2 deletions packages/snap/snap.config.js

This file was deleted.

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": "https://github.com/filecoin-project/filsnap.git"
},
"source": {
"shasum": "qbaANkQDYbjxJRrqp3rkALqUq7h6rTaePkyVvb8Oziw=",
"shasum": "YmjoCze1pMpnlPZBGuE7+b0SjFlhOTOIjBBEgajedmg=",
"location": {
"npm": {
"filePath": "dist/snap.js",
Expand Down
6 changes: 3 additions & 3 deletions packages/snap/src/account.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getBIP44AddressKeyDeriver } from '@metamask/key-tree'
import { type SnapsGlobalObject } from '@metamask/snaps-types'
import { type SnapsProvider } from '@metamask/snaps-sdk'
import { accountFromPrivateKey } from 'iso-filecoin/wallet'
import { parseDerivationPath } from 'iso-filecoin/utils'
import type { AddressBLS, AddressSecp256k1 } from 'iso-filecoin/address'
Expand All @@ -12,7 +12,7 @@ import type { Account, SnapConfig } from './types'
* @param config - Snap configuration
*/
export async function getAccount(
snap: SnapsGlobalObject,
snap: SnapsProvider,
config: SnapConfig
): Promise<Account> {
const { derivationPath } = config
Expand Down Expand Up @@ -52,7 +52,7 @@ export async function getAccount(
* @param config - Snap configuration
*/
export async function getAccountSafe(
snap: SnapsGlobalObject,
snap: SnapsProvider,
config: SnapConfig
): Promise<{ address: AddressSecp256k1 | AddressBLS; pubKey: Uint8Array }> {
const { derivationPath } = config
Expand Down
8 changes: 3 additions & 5 deletions packages/snap/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { OnRpcRequestHandler } from '@metamask/snaps-types'
import type { OnRpcRequestHandler } from '@metamask/snaps-sdk'
import { hex } from 'iso-base/rfc4648'
import { configure } from './rpc/configure'
import { exportPrivateKey } from './rpc/export-private-key'
import { type EstimateParams, getGasForMessage } from './rpc/gas-for-message'
import { getBalance } from './rpc/get-balance'
import { sendMessage } from './rpc/send-message'
import { type SignedMessage, sendMessage } from './rpc/send-message'

import { getAccountSafe } from './account'
import { getAccountInfo } from './rpc/get-account'
Expand All @@ -28,9 +28,7 @@ export type {
export { onTransaction } from './transaction-insight'

export const onRpcRequest: OnRpcRequestHandler = async ({
// @ts-expect-error - TODO: fix this
origin,
// @ts-expect-error - TODO: fix this
request,
}) => {
try {
Expand Down Expand Up @@ -88,7 +86,7 @@ export const onRpcRequest: OnRpcRequestHandler = async ({
)
}
case 'fil_sendMessage': {
return await sendMessage(context, request.params)
return await sendMessage(context, request.params as SignedMessage)
}
case 'fil_getGasForMessage': {
return await getGasForMessage(context, request.params as EstimateParams)
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/rpc/configure.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-expect-error - no types for this package
import merge from 'merge-options'
import { copyable, panel, text } from '@metamask/snaps-ui'
import { copyable, panel, text } from '@metamask/snaps-sdk'
import { RPC } from 'iso-filecoin/rpc'
import { parseDerivationPath } from 'iso-filecoin/utils'
import { snapConfig } from '../schemas'
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/rpc/export-private-key.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { copyable, divider, panel, text } from '@metamask/snaps-ui'
import { copyable, divider, panel, text } from '@metamask/snaps-sdk'
import { base64pad } from 'iso-base/rfc4648'
import { parseDerivationPath } from 'iso-filecoin/utils'
import type { SnapContext, SnapResponse } from '../types'
Expand Down
5 changes: 4 additions & 1 deletion packages/snap/src/rpc/gas-for-message.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Schemas } from 'iso-filecoin/message'
import { z } from 'zod'
import type { Jsonify } from 'type-fest'

import * as Address from 'iso-filecoin/address'
import { RPC } from 'iso-filecoin/rpc'
import type { SnapContext, SnapResponse } from '../types'
Expand Down Expand Up @@ -42,6 +44,7 @@ export interface MessageGasEstimate {
*/
gasPremium: string
}

export type GasForMessageResponse = SnapResponse<MessageGasEstimate>

/**
Expand All @@ -53,7 +56,7 @@ export type GasForMessageResponse = SnapResponse<MessageGasEstimate>
export async function getGasForMessage(
ctx: SnapContext,
params: EstimateParams
): Promise<GasForMessageResponse> {
): Promise<Jsonify<GasForMessageResponse>> {
const { state } = ctx
const config = await state.get(ctx.origin)
if (config == null) {
Expand Down
Loading

0 comments on commit 1d6ddb0

Please sign in to comment.