Skip to content
Draft
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
16 changes: 10 additions & 6 deletions jest.config.packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,23 @@ module.exports = {
// ],

// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
// Here we ensure that Jest resolves `@metamask/*` imports to the uncompiled source code for packages that live in this repo.
// NOTE: This must be synchronized with the `paths` option in `tsconfig.base.json`.
// Resolve workspace `@metamask/*` imports to uncompiled source. Paths are
// relative to the monorepo root, not to the consuming package. When a local
// `packages/<name>/src` directory does not exist, use the installed package.
// NOTE: This must be synchronized with the `paths` option in `tsconfig.packages.json`.
moduleNameMapper: {
'^@metamask/json-rpc-engine/v2$': [
'<rootDir>/../json-rpc-engine/src/v2/index.ts',
],
'^@metamask/utils/node$': require.resolve('@metamask/utils/node'),
'^@metamask/(.+)$': [
'<rootDir>/../$1/src',
// Some @metamask/* packages we are referencing aren't in this monorepo,
// so in that case use their published versions
'^@metamask/([^/]+)$': [
'<rootDir>/../../packages/$1/src',
'<rootDir>/../../node_modules/@metamask/$1',
],
'^@metamask/([^/]+)/(.+)$': [
'<rootDir>/../../packages/$1/src/$2',
'<rootDir>/../../node_modules/@metamask/$1/$2',
],
},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
Expand Down
4 changes: 4 additions & 0 deletions packages/bitcoin-wallet-snap/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Resolve workspace `@metamask/*` TypeScript types from the monorepo root instead of assuming sibling directories ([#167](https://github.com/MetaMask/internal-snaps/pull/167))

## [2.0.1]

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion packages/bitcoin-wallet-snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/internal-snaps.git"
},
"source": {
"shasum": "jV649WZbbfbj3FpOMD5U/xDPuRD0t4F+pxCoy08a/O0=",
"shasum": "PpNYFDDadcYp9uuFWMdaURUB5G8vsXrwOETgpFEzUW4=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
12 changes: 2 additions & 10 deletions packages/bitcoin-wallet-snap/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
{
"extends": "../../tsconfig.packages.json",
"extends": "../../tsconfig.snaps.json",
"compilerOptions": {
"baseUrl": "./",
"lib": ["ES2021", "DOM"],
"resolveJsonModule": true /* lets us import JSON modules from within TypeScript modules. */,
"jsx": "react-jsx",
"jsxImportSource": "@metamask/snaps-sdk",
"exactOptionalPropertyTypes": false,
"forceConsistentCasingInFileNames": true,
"noErrorTruncation": true,
"noUncheckedIndexedAccess": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"types": ["jest"]
"noUncheckedIndexedAccess": true
},
"include": ["**/*.ts", "**/*.tsx", "locales/*.json"]
}
9 changes: 1 addition & 8 deletions packages/sample-snap/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
{
"extends": "../../tsconfig.packages.json",
"compilerOptions": {
"baseUrl": "./",
"jsx": "react-jsx",
"skipLibCheck": true,
"jsxImportSource": "@metamask/snaps-sdk",
"types": ["jest"]
},
"extends": "../../tsconfig.snaps.json",
"include": ["**/*.ts", "**/*.tsx", "locales/*.json"]
}
4 changes: 4 additions & 0 deletions packages/snap-networks-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Bump `@metamask/utils` from `^11.9.0` to `^11.11.9` ([#161](https://github.com/MetaMask/internal-snaps/pull/161))

### Fixed

- Assign optional `Logger` `prefix` and `decorators` only when they are provided so `exactOptionalPropertyTypes` consumers can typecheck against workspace source ([#167](https://github.com/MetaMask/internal-snaps/pull/167))

## [1.0.0]

### Added
Expand Down
12 changes: 9 additions & 3 deletions packages/snap-networks-utils/src/logger/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,12 @@ export class Logger {
assert(level, LogLevelStruct);

this.#level = level;
this.#prefix = prefix;
this.#decorators = decorators;
if (prefix !== undefined) {
this.#prefix = prefix;
}
if (decorators !== undefined) {
this.#decorators = decorators;
}
}

/**
Expand All @@ -146,7 +150,9 @@ export class Logger {
return new Logger({
level: this.#level,
prefix: this.#prefix ? `${this.#prefix} ${prefix}` : prefix,
decorators: this.#decorators,
...(this.#decorators === undefined
? {}
: { decorators: this.#decorators }),
});
}

Expand Down
1 change: 0 additions & 1 deletion packages/snap-networks-utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "../../tsconfig.packages.json",
"compilerOptions": {
"baseUrl": "./",
"skipLibCheck": true,
"types": ["jest"]
},
Expand Down
1 change: 1 addition & 0 deletions packages/solana-wallet-snap/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Resolve workspace `@metamask/*` TypeScript types from the monorepo root instead of assuming sibling directories ([#167](https://github.com/MetaMask/internal-snaps/pull/167))
- Extract Snap-owned assets domain logic into `SnapAssetsAdapter`; `AssetsService` is a thin facade that delegates metadata, market data, fetch, persist, and account asset reads through the adapter (no Core routing yet). ([#121](https://github.com/MetaMask/internal-snaps/pull/121))
- Align `AssetsService` read API with `snap-networks-utils` / AssetsController shapes by adding `getAccountAssetByID`, `getAccountAssetsByIDs`, `getAccountAssetsByScope`, and `getAccountAssets`, and routing Keyring and Send through them (still Snap-owned storage). ([#120](https://github.com/MetaMask/internal-snaps/pull/120))

Expand Down
2 changes: 1 addition & 1 deletion packages/solana-wallet-snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/internal-snaps.git"
},
"source": {
"shasum": "2c2WNzBfLdP/UYJdepbBVpyYrpjzuSob/iobC9JJRLo=",
"shasum": "ogadUr7kiFH3ZTJLvNrBtK3z9EpDy1UGFLA+DSe0XVU=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
21 changes: 10 additions & 11 deletions packages/solana-wallet-snap/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
{
"extends": "../../tsconfig.packages.json",
"extends": "../../tsconfig.snaps.json",
"compilerOptions": {
"baseUrl": "./",
"jsx": "react-jsx",
"jsxImportSource": "@metamask/snaps-sdk",
"resolveJsonModule": true,
"paths": {
"@metamask/*": ["../../packages/*/src"],
"@metamask/snap-networks-utils/*": [
"../../packages/snap-networks-utils/src/*"
]
},
"lib": ["ES2023", "DOM"],
"target": "es2023",
"exactOptionalPropertyTypes": true,
"forceConsistentCasingInFileNames": true,
"noErrorTruncation": true,
"noUncheckedIndexedAccess": true,
"skipLibCheck": true,
"lib": ["ES2023", "DOM"],
"target": "es2023",
"module": "preserve",
"moduleResolution": "bundler",
"types": ["jest"]
"noUncheckedIndexedAccess": true
},
"include": ["**/*.ts", "**/*.tsx", "locales/*.json"]
}
1 change: 1 addition & 0 deletions packages/stellar-wallet-snap/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Resolve workspace `@metamask/*` TypeScript types from the monorepo root instead of assuming sibling directories ([#167](https://github.com/MetaMask/internal-snaps/pull/167))
- This package was migrated from [snap-stellar-wallet](https://github.com/MetaMask/snap-stellar-wallet). See the source repository for the original [changelog](https://github.com/MetaMask/snap-stellar-wallet/blob/main/packages/snap/CHANGELOG.md) ([#161](https://github.com/MetaMask/internal-snaps/pull/161))

### Fixed
Expand Down
15 changes: 4 additions & 11 deletions packages/stellar-wallet-snap/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
{
"extends": "../../tsconfig.packages.json",
"extends": "../../tsconfig.snaps.json",
"compilerOptions": {
"resolveJsonModule": true /* lets us import JSON modules from within TypeScript modules. */,
"jsx": "react-jsx",
"jsxImportSource": "@metamask/snaps-sdk",
"lib": ["ES2023", "DOM"],
"target": "es2023",
"exactOptionalPropertyTypes": false,
"forceConsistentCasingInFileNames": true,
"noErrorTruncation": true,
"noUncheckedIndexedAccess": true,
"skipLibCheck": true,
"lib": ["ES2023", "DOM"],
"target": "es2023",
"module": "preserve",
"moduleResolution": "bundler",
"types": ["jest"]
"noUncheckedIndexedAccess": true
},
"include": ["**/*.ts", "**/*.tsx", "locales/*.json"]
}
1 change: 1 addition & 0 deletions packages/tron-wallet-snap/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Resolve workspace `@metamask/*` TypeScript types from the monorepo root instead of assuming sibling directories ([#167](https://github.com/MetaMask/internal-snaps/pull/167))
- Extract shared asset util functions and inject `SnapAssetsAdapter` from `context` into `AssetsService` ([#143](https://github.com/MetaMask/internal-snaps/pull/143))
- Rename `getByKeyringAccountId` to `getAccountAssets` (with essential-asset synthesis) and update keyring callers ([#143](https://github.com/MetaMask/internal-snaps/pull/143))

Expand Down
2 changes: 1 addition & 1 deletion packages/tron-wallet-snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/internal-snaps.git"
},
"source": {
"shasum": "MbqwOXbHFI83/qWOj9zDSXJizgEt5oQ+QnpHq0g/sls=",
"shasum": "Dgq9UwYX7J/Mo+Ubvm4cwZGPlea3fC/CPtq7jJhReec=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
15 changes: 4 additions & 11 deletions packages/tron-wallet-snap/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
{
"extends": "../../tsconfig.packages.json",
"extends": "../../tsconfig.snaps.json",
"compilerOptions": {
"resolveJsonModule": true /* lets us import JSON modules from within TypeScript modules. */,
"jsx": "react-jsx",
"jsxImportSource": "@metamask/snaps-sdk",
"lib": ["ES2023", "DOM"],
"target": "es2023",
"exactOptionalPropertyTypes": false,
"forceConsistentCasingInFileNames": true,
"noErrorTruncation": true,
"noUncheckedIndexedAccess": true,
"skipLibCheck": true,
"lib": ["ES2023", "DOM"],
"target": "es2023",
"module": "preserve",
"moduleResolution": "bundler",
"types": ["jest"]
"noUncheckedIndexedAccess": true
},
"include": ["**/*.ts", "**/*.tsx", "locales/*.json"]
}
3 changes: 0 additions & 3 deletions scripts/create-package/package-template/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"extends": "../../tsconfig.packages.json",
"compilerOptions": {
"baseUrl": "./"
},
"references": [],
"include": ["../../types", "./src"]
}
17 changes: 13 additions & 4 deletions tsconfig.packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,23 @@
"extends": "./tsconfig.base.json",
"compilerOptions": {
/**
* Here we ensure that TypeScript resolves `@metamask/*` imports to the
* uncompiled source code for packages that live in this repo.
* Resolve `@metamask/*` imports to uncompiled source for packages in this
* repo. Paths are relative to this file (the monorepo root).
*
* A local candidate is used only when `packages/<name>/src` exists.
* Published `@metamask/*` dependencies fall through to `node_modules`.
* TypeScript path patterns allow only one `*`, so workspace packages
* with extra entry points need an explicit subpath mapping.
*
* NOTE: This must be synchronized with the `moduleNameMapper` option in
* `jest.config.packages.js`.
* `jest.config.packages.js`. Consuming configs should not set `baseUrl`
* unless they also re-declare these paths relative to that `baseUrl`.
*/
"paths": {
"@metamask/*": ["../*/src"]
"@metamask/*": ["./packages/*/src"],
"@metamask/snap-networks-utils/*": [
"./packages/snap-networks-utils/src/*"
]
}
}
}
25 changes: 25 additions & 0 deletions tsconfig.snaps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
/**
* Shared TypeScript settings for Snap packages.
*
* Snaps are bundled with `mm-snap` and are not part of the root
* `tsc --build` graph, so `composite` is disabled here. That lets
* workspace `@metamask/*` path mappings resolve to sibling `src/`
* directories without requiring project-reference build artifacts.
*
* Do not set `baseUrl` here. Inherited path mappings are resolved
* against `baseUrl` when it is present, which would break the
* monorepo-root mappings in `tsconfig.packages.json`.
*/
"extends": "./tsconfig.packages.json",
"compilerOptions": {
"composite": false,
"jsx": "react-jsx",
"jsxImportSource": "@metamask/snaps-sdk",
"module": "preserve",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"skipLibCheck": true,
"types": ["jest"]
}
}