Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/examples/examples/browserify/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps-monorepo.git"
},
"source": {
"shasum": "c8hLUTgqFJnm0GgK1XcEW1RbqBxukctXTYqe2av7khk=",
"shasum": "lcCxQquYyEkQGnVdLJZTtXoEGI20tENIG9TRTsLwEmI=",
"location": {
"npm": {
"filePath": "dist/snap.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/examples/examples/browserify/src/snap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const onRpcRequest: OnRpcRequestHandler = async ({
}) => {
switch (request.method) {
case 'inApp':
return snap.request({
return await snap.request({
method: 'snap_notify',
params: [
{
Expand All @@ -27,7 +27,7 @@ export const onRpcRequest: OnRpcRequestHandler = async ({
],
});
case 'native':
return snap.request({
return await snap.request({
method: 'snap_notify',
params: [
{
Expand Down
1 change: 0 additions & 1 deletion packages/examples/examples/browserify/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
"compilerOptions": {
"resolveJsonModule": true
},
"files": ["../../../snaps-types/global.d.ts"],
"include": ["src", "gulpfile.ts", "babel.config.json"]
}
6 changes: 0 additions & 6 deletions packages/examples/examples/insights/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,3 @@ This Snap demonstrates how to use the transaction insights feature.

- Babel is used for transpiling TypeScript to JavaScript, so when building with the CLI,
`transpilationMode` must be set to `localOnly` (default) or `localAndDeps`.
- For the global `wallet` type to work, you have to add the following to your `tsconfig.json`:
```json
{
"files": ["./node_modules/@metamask/snaps-types/global.d.ts"]
}
```
1 change: 0 additions & 1 deletion packages/examples/examples/insights/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
"compilerOptions": {
"typeRoots": ["../../../../node_modules/@types"]
},
"files": ["../../../snaps-types/global.d.ts"],
"include": ["src"]
}
1 change: 0 additions & 1 deletion packages/examples/examples/rollup/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
"declaration": false,
"typeRoots": ["../../../../node_modules/@types"]
},
"files": ["../../../snaps-types/global.d.ts"],
"include": ["src"]
}
6 changes: 0 additions & 6 deletions packages/examples/examples/typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,3 @@ This Snap demonstrates how to develop a Snap with TypeScript.

- Babel is used for transpiling TypeScript to JavaScript, so when building with the CLI,
`transpilationMode` must be set to `localOnly` (default) or `localAndDeps`.
- For the global `wallet` type to work, you have to add the following to your `tsconfig.json`:
```json
{
"files": ["./node_modules/@metamask/snaps-types/global.d.ts"]
}
```
1 change: 0 additions & 1 deletion packages/examples/examples/typescript/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
"compilerOptions": {
"typeRoots": ["../../../../node_modules/@types"]
},
"files": ["../../../snaps-types/global.d.ts"],
"include": ["src"]
}
1 change: 0 additions & 1 deletion packages/examples/examples/wasm/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
"declaration": false,
"typeRoots": ["../../../../node_modules/@types"]
},
"files": ["../../../snaps-types/global.d.ts"],
"include": ["assembly"]
}
1 change: 0 additions & 1 deletion packages/examples/examples/webpack/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
"compilerOptions": {
"typeRoots": ["../../../../node_modules/@types"]
},
"files": ["../../../snaps-types/global.d.ts"],
"include": ["src", "webpack.config.ts"]
}
1 change: 0 additions & 1 deletion packages/snaps-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"@metamask/post-message-stream": "^6.0.0",
"@metamask/rpc-methods": "^0.26.2",
"@metamask/snaps-execution-environments": "^0.26.2",
"@metamask/snaps-types": "^0.26.2",
"@metamask/snaps-utils": "^0.26.2",
"@metamask/subject-metadata-controller": "^1.0.1",
"@metamask/utils": "^3.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
HasPermission,
PermissionConstraint,
} from '@metamask/permission-controller';
import { SnapKeyring } from '@metamask/snaps-types';
import {
SnapKeyring,
parseAccountId,
AccountId,
parseChainId,
Expand Down
1 change: 0 additions & 1 deletion packages/snaps-execution-environments/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"@metamask/object-multiplex": "^1.2.0",
"@metamask/post-message-stream": "^6.0.0",
"@metamask/providers": "^10.2.0",
"@metamask/snaps-types": "^0.26.2",
"@metamask/snaps-utils": "^0.26.2",
"@metamask/utils": "^3.3.1",
"eth-rpc-errors": "^4.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
/// <reference path="../../../../node_modules/ses/index.d.ts" />
import { StreamProvider } from '@metamask/providers';
import { RequestArguments } from '@metamask/providers/dist/BaseProvider';
import { SnapExports, SnapsGlobalObject } from '@metamask/snaps-types';
import {
SnapExports,
SnapsGlobalObject,
HandlerType,
SnapExportsParameters,
SNAP_EXPORT_NAMES,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { StreamProvider } from '@metamask/providers';
import { SnapsGlobalObject } from '@metamask/snaps-types';
import { SnapsGlobalObject } from '@metamask/snaps-utils';
import { hasProperty } from '@metamask/utils';

import { rootRealmGlobal } from '../globalObject';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SnapKeyring } from '@metamask/snaps-types';
import { SnapKeyring } from '@metamask/snaps-utils';
import {
assert,
isValidJson,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { SnapKeyring } from '@metamask/snaps-types';
import { ChainIdStruct, HandlerType } from '@metamask/snaps-utils';
import { SnapKeyring, ChainIdStruct, HandlerType } from '@metamask/snaps-utils';
import {
assertStruct,
Json,
Expand Down
13 changes: 8 additions & 5 deletions packages/snaps-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,27 @@
"type": "git",
"url": "https://github.com/MetaMask/snaps-monorepo.git"
},
"main": "src/index.d.ts",
"types": "src/index.d.ts",
"main": "dist/index.d.ts",
"types": "dist/index.d.ts",
"files": [
"src",
"global.d.ts"
"dist"
],
"scripts": {
"lint:eslint": "eslint . --cache --ext js,ts",
"lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' --ignore-path ../../.gitignore",
"lint": "yarn lint:eslint && yarn lint:misc --check",
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
"lint:changelog": "yarn auto-changelog validate",
"build:tsc": "tsc --project tsconfig.build.json",
"build": "yarn build:tsc",
"build:clean": "yarn clean && yarn build",
"clean": "rimraf '*.tsbuildinfo' 'dist/*'",
"publish:package": "../../scripts/publish-package.sh"
},
"dependencies": {
"@metamask/providers": "^10.2.0",
"@metamask/snaps-utils": "^0.26.2",
"@metamask/types": "^1.1.0"
"@metamask/utils": "^3.3.1"
},
"devDependencies": {
"@lavamoat/allow-scripts": "^2.0.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MetaMaskInpageProvider } from '@metamask/providers';
import { SnapsGlobalObject } from './src';
import { SnapsGlobalObject } from '@metamask/snaps-utils';

// Types that should be available globally within a Snap
// Types that should be available globally within a snap.
declare global {
const ethereum: MetaMaskInpageProvider;
const snap: SnapsGlobalObject;
Expand Down
1 change: 0 additions & 1 deletion packages/snaps-types/src/index.d.ts

This file was deleted.

4 changes: 4 additions & 0 deletions packages/snaps-types/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// eslint-disable-next-line import/no-unassigned-import
import './global';

export * from './types';
72 changes: 0 additions & 72 deletions packages/snaps-types/src/types.d.ts

This file was deleted.

22 changes: 22 additions & 0 deletions packages/snaps-types/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { StreamProvider } from '@metamask/providers';

/**
* The type of `window.ethereum`.
*/
export type Ethereum = StreamProvider;

// Exported again for convenience.
export type { Json, JsonRpcRequest } from '@metamask/utils';
export type {
AccountId,
ChainId,
KeyringEvent,
KeyringRequest,
OnCronjobHandler,
OnRpcRequestHandler,
OnTransactionHandler,
OnTransactionResponse,
RequestArguments,
SnapKeyring,
SnapsGlobalObject,
} from '@metamask/snaps-utils';
15 changes: 15 additions & 0 deletions packages/snaps-types/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../tsconfig.packages.build.json",
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist",
"rootDir": "./src",
"emitDeclarationOnly": true
},
"include": ["./src"],
"references": [
{
"path": "../snaps-utils/tsconfig.build.json"
}
]
}
7 changes: 6 additions & 1 deletion packages/snaps-types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
"compilerOptions": {
"baseUrl": "./"
},
"include": ["./src"]
"include": ["./src"],
"references": [
{
"path": "../snaps-utils"
}
]
}
8 changes: 4 additions & 4 deletions packages/snaps-utils/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ module.exports = deepmerge(baseConfig, {
],
coverageThreshold: {
global: {
branches: 94.6,
functions: 98.92,
lines: 98.99,
statements: 98.99,
branches: 94.42,
functions: 97.95,
lines: 95.11,
statements: 95.11,
},
},
testTimeout: 2500,
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"dependencies": {
"@babel/core": "^7.18.6",
"@babel/types": "^7.18.7",
"@metamask/snaps-types": "^0.26.2",
"@metamask/providers": "^10.2.1",
"@metamask/utils": "^3.3.1",
"@noble/hashes": "^1.1.3",
"@scure/base": "^1.1.1",
Expand Down
Loading