Skip to content

Commit

Permalink
fix: depcheck (#119)
Browse files Browse the repository at this point in the history
`depcheck` was not running properly. It has to be invoked with `yarn
workspaces foreach`.
  • Loading branch information
ccharly authored Dec 6, 2024
1 parent 0488168 commit cf65e26
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 27 deletions.
10 changes: 10 additions & 0 deletions .depcheckrc.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
---
ignore-patterns:
- '.yarn'
- 'dist/'
ignores:
# Ignore depcheck itself (seems to be required for monorepos)
- 'depcheck'
# Ignore tsd even if it not used yet in some packages
- 'tsd'
# Ignore dependencies imported implicitly by TypeScript
- '@types/*'
# Ignore peer dependencies that appears unused, but are required
- 'webextension-polyfill'
# Ignore tools (packages which we use as executables and not libraries)
- 'rimraf'
- '@lavamoat/allow-scripts'
Expand All @@ -21,3 +28,6 @@ ignores:
# @metamask/eth-ledger-bridge-keyring
- '@ledgerhq/types-cryptoassets'
- '@ledgerhq/types-devices'
# Ignore dependency that is used with jest "directives" (thus, they cannot be detected
# by depcheck properly)
- 'jest-environment-jsdom'
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@
"scripts": {
"build": "ts-bridge --project tsconfig.build.json",
"build:clean": "yarn build --clean",
"build:docs": "yarn workspaces foreach --all --no-private --parallel --interlaced --verbose run build:docs",
"build:docs": "yarn foreach build:docs",
"foreach": "yarn workspaces foreach --all --parallel --verbose --exclude '@metamask/accounts-monorepo' run",
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn constraints && yarn lint:dependencies",
"lint:dependencies": "depcheck && yarn dedupe --check && syncpack list-mismatches",
"lint:dependencies:fix": "depcheck && yarn dedupe && syncpack fix-mismatches",
"lint:dependencies": "yarn foreach depcheck && yarn dedupe --check && syncpack list-mismatches",
"lint:dependencies:fix": "yarn foreach depcheck && yarn dedupe && syncpack fix-mismatches",
"lint:eslint": "eslint . --cache --ext js,cjs,mjs,ts",
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write && yarn constraints --fix && yarn lint:dependencies:fix",
"lint:misc": "prettier '**/*.json' '**/*.md' '!**/CHANGELOG.old.md' '**/*.yml' '!.yarnrc.yml' '!merged-packages/**' --ignore-path .gitignore",
"prepare:preview": "ts-node --project tsconfig.scripts.json scripts/prepare-preview-builds.ts",
"prepare:preview:local": "yarn prepare:preview @metamask-previews $(git rev-parse --short HEAD)",
"publish:preview": "yarn workspaces foreach --all --no-private --parallel --verbose run publish:preview",
"publish:preview": "yarn foreach publish:preview",
"readme:update": "ts-node --project tsconfig.scripts.json scripts/update-readme-content.ts",
"release": "./scripts/release.sh",
"setup": "yarn install",
"test": "yarn workspaces foreach --all --parallel --verbose run test",
"test:clean": "yarn workspaces foreach --all --parallel --verbose run test:clean"
"test": "yarn foreach test",
"test:clean": "yarn foreach test:clean"
},
"resolutions": {
"@types/node": "^20.12.12",
Expand Down
8 changes: 5 additions & 3 deletions packages/keyring-eth-trezor/src/trezor-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import type {
EthereumSignTypedHash,
} from '@trezor/connect-web';

// TrezorConnect.getPublicKey has two overloads
// It is not possible to extract them from the library using utility types
export type ExtendedPublicKey = { publicKey: string; chainCode: string };

export interface TrezorBridge {
model?: string;

Expand All @@ -22,12 +26,10 @@ export interface TrezorBridge {

dispose(): Promise<void>;

// TrezorConnect.getPublicKey has two overloads
// It is not possible to extract them from the library using utility types
getPublicKey(params: {
path: string;
coin: string;
}): Response<{ publicKey: string; chainCode: string }>;
}): Response<ExtendedPublicKey>;

ethereumSignTransaction(
params: Params<EthereumSignTransaction>,
Expand Down
5 changes: 2 additions & 3 deletions packages/keyring-eth-trezor/src/trezor-connect-bridge.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { HDNodeResponse } from '@trezor/connect/lib/types/api/getPublicKey';
import TrezorConnect, { DEVICE_EVENT, DEVICE } from '@trezor/connect-web';
import type {
EthereumSignedTx,
Expand All @@ -13,7 +12,7 @@ import type {
EthereumSignTypedHash,
} from '@trezor/connect-web';

import type { TrezorBridge } from './trezor-bridge';
import type { TrezorBridge, ExtendedPublicKey } from './trezor-bridge';

export class TrezorConnectBridge implements TrezorBridge {
model?: string;
Expand Down Expand Up @@ -51,7 +50,7 @@ export class TrezorConnectBridge implements TrezorBridge {
getPublicKey(params: {
path: string;
coin: string;
}): Response<HDNodeResponse> {
}): Response<ExtendedPublicKey> {
return TrezorConnect.getPublicKey(params);
}

Expand Down
14 changes: 12 additions & 2 deletions packages/keyring-snap-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
"changelog:update": "../../scripts/update-changelog.sh @metamask/eth-snap-keyring",
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/eth-snap-keyring",
"publish:preview": "yarn npm publish --tag preview",
"test": "jest && jest-it-up",
"test": "yarn test:source && yarn test:types",
"test:clean": "jest --clearCache",
"test:source": "jest && jest-it-up",
"test:types": "../../scripts/tsd-test.sh ./src",
"test:watch": "jest --watch"
},
"dependencies": {
Expand All @@ -46,7 +48,8 @@
"@metamask/superstruct": "^3.1.0",
"@metamask/utils": "^9.3.0",
"@types/uuid": "^9.0.8",
"uuid": "^9.0.1"
"uuid": "^9.0.1",
"webextension-polyfill": "^0.12.0"
},
"devDependencies": {
"@lavamoat/allow-scripts": "^3.2.1",
Expand All @@ -62,6 +65,7 @@
"jest-it-up": "^3.1.0",
"ts-jest": "^29.0.5",
"ts-node": "^10.9.2",
"tsd": "^0.31.0",
"typedoc": "^0.25.13",
"typescript": "~5.6.3"
},
Expand All @@ -83,5 +87,11 @@
"@metamask/snaps-controllers>@metamask/phishing-controller>@metamask/controller-utils>ethereumjs-util>ethereum-cryptography>keccak": false,
"@metamask/snaps-controllers>@metamask/phishing-controller>@metamask/controller-utils>ethereumjs-util>ethereum-cryptography>secp256k1": false
}
},
"tsd": {
"directory": "src",
"compilerOptions": {
"composite": "false"
}
}
}
7 changes: 5 additions & 2 deletions packages/keyring-snap-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"test": "yarn test:source && yarn test:types",
"test:clean": "jest --clearCache",
"test:source": "jest && jest-it-up",
"test:types": "echo 'No tests to run for now'",
"test:types": "../../scripts/tsd-test.sh ./src",
"test:watch": "jest --watch"
},
"dependencies": {
Expand Down Expand Up @@ -88,6 +88,9 @@
}
},
"tsd": {
"directory": "src"
"directory": "src",
"compilerOptions": {
"composite": "false"
}
}
}
10 changes: 5 additions & 5 deletions packages/keyring-snap-internal-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"test": "yarn test:source && yarn test:types",
"test:clean": "jest --clearCache",
"test:source": "jest && jest-it-up",
"test:types": "echo 'No tests to run for now'",
"test:types": "../../scripts/tsd-test.sh ./src",
"test:watch": "jest --watch"
},
"dependencies": {
Expand All @@ -51,9 +51,6 @@
"@metamask/snaps-controllers": "^9.10.0",
"@metamask/snaps-sdk": "^6.7.0",
"@metamask/snaps-utils": "^8.3.0",
"@metamask/superstruct": "^3.1.0",
"@types/uuid": "^9.0.8",
"uuid": "^9.0.1",
"webextension-polyfill": "^0.12.0"
},
"devDependencies": {
Expand Down Expand Up @@ -92,6 +89,9 @@
}
},
"tsd": {
"directory": "src"
"directory": "src",
"compilerOptions": {
"composite": "false"
}
}
}
10 changes: 7 additions & 3 deletions packages/keyring-snap-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@
"test": "yarn test:source && yarn test:types",
"test:clean": "jest --clearCache",
"test:source": "jest && jest-it-up",
"test:types": "echo 'No tests to run for now'",
"test:types": "../../scripts/tsd-test.sh ./src",
"test:watch": "jest --watch"
},
"dependencies": {
"@metamask/keyring-utils": "workspace:^",
"@metamask/snaps-sdk": "^6.7.0",
"@metamask/superstruct": "^3.1.0",
"@metamask/utils": "^9.3.0"
"@metamask/utils": "^9.3.0",
"webextension-polyfill": "^0.12.0"
},
"devDependencies": {
"@lavamoat/allow-scripts": "^3.2.1",
Expand Down Expand Up @@ -86,6 +87,9 @@
}
},
"tsd": {
"directory": "src"
"directory": "src",
"compilerOptions": {
"composite": "false"
}
}
}
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2016,9 +2016,11 @@ __metadata:
jest-it-up: "npm:^3.1.0"
ts-jest: "npm:^29.0.5"
ts-node: "npm:^10.9.2"
tsd: "npm:^0.31.0"
typedoc: "npm:^0.25.13"
typescript: "npm:~5.6.3"
uuid: "npm:^9.0.1"
webextension-polyfill: "npm:^0.12.0"
peerDependencies:
"@metamask/keyring-api": "workspace:^"
"@metamask/providers": ^18.1.0
Expand Down Expand Up @@ -2234,12 +2236,10 @@ __metadata:
"@metamask/snaps-controllers": "npm:^9.10.0"
"@metamask/snaps-sdk": "npm:^6.7.0"
"@metamask/snaps-utils": "npm:^8.3.0"
"@metamask/superstruct": "npm:^3.1.0"
"@metamask/utils": "npm:^9.3.0"
"@ts-bridge/cli": "npm:^0.6.0"
"@types/jest": "npm:^29.5.12"
"@types/node": "npm:^20.12.12"
"@types/uuid": "npm:^9.0.8"
deepmerge: "npm:^4.2.2"
depcheck: "npm:^1.4.7"
jest: "npm:^29.5.0"
Expand All @@ -2250,7 +2250,6 @@ __metadata:
tsd: "npm:^0.31.0"
typedoc: "npm:^0.25.13"
typescript: "npm:~5.6.3"
uuid: "npm:^9.0.1"
webextension-polyfill: "npm:^0.12.0"
peerDependencies:
"@metamask/providers": ^18.1.0
Expand Down Expand Up @@ -2283,6 +2282,7 @@ __metadata:
tsd: "npm:^0.31.0"
typedoc: "npm:^0.25.13"
typescript: "npm:~5.6.3"
webextension-polyfill: "npm:^0.12.0"
peerDependencies:
"@metamask/providers": ^18.1.0
languageName: unknown
Expand Down

0 comments on commit cf65e26

Please sign in to comment.