diff --git a/packages/examples/packages/name-lookup/package.json b/packages/examples/packages/name-lookup/package.json index cd79c30158..f5fd64a9c3 100644 --- a/packages/examples/packages/name-lookup/package.json +++ b/packages/examples/packages/name-lookup/package.json @@ -32,8 +32,7 @@ "lint:dependencies": "depcheck" }, "dependencies": { - "@metamask/snaps-types": "workspace:^", - "@metamask/utils": "^8.1.0" + "@metamask/snaps-types": "workspace:^" }, "devDependencies": { "@jest/globals": "^29.5.0", diff --git a/packages/examples/packages/name-lookup/snap.manifest.json b/packages/examples/packages/name-lookup/snap.manifest.json index e83a13eb4f..ad739078b6 100644 --- a/packages/examples/packages/name-lookup/snap.manifest.json +++ b/packages/examples/packages/name-lookup/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "gg1ORyP0Yf+ypmuaTRCGqvtmGwvVSWCWtIKnjjfg+fI=", + "shasum": "7aIi2VIfpdpkMONT21Q/1m1mx9Mu7qYVmTy0Jkb+O9s=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/name-lookup/src/index.test.ts b/packages/examples/packages/name-lookup/src/index.test.ts index 7d5c91a912..633ee9fa1b 100644 --- a/packages/examples/packages/name-lookup/src/index.test.ts +++ b/packages/examples/packages/name-lookup/src/index.test.ts @@ -26,7 +26,7 @@ describe('onNameLookup', () => { }; expect(await onNameLookup(request)).toStrictEqual({ - resolvedDomain: 'example.domain - 0xc0f / 0x1', + resolvedDomain: 'c0f.1.test.domain', }); }); @@ -38,7 +38,7 @@ describe('onNameLookup', () => { } as any; expect(await onNameLookup(request)).toStrictEqual({ - resolvedDomain: 'example.domain - 0xc0f / 0x1', + resolvedDomain: 'c0f.1.test.domain', }); }); diff --git a/packages/examples/packages/name-lookup/src/index.ts b/packages/examples/packages/name-lookup/src/index.ts index ac2b4e2044..b547f831f8 100644 --- a/packages/examples/packages/name-lookup/src/index.ts +++ b/packages/examples/packages/name-lookup/src/index.ts @@ -1,5 +1,4 @@ import type { OnNameLookupHandler } from '@metamask/snaps-types'; -import { numberToHex } from '@metamask/utils'; /** * Handle incoming name lookup requests from the MetaMask clients. @@ -15,10 +14,9 @@ export const onNameLookup: OnNameLookupHandler = async (request) => { const { chainId, address, domain } = request; if (address) { - const shortAddress = `0x${address.substring(2, 5)}`; + const shortAddress = address.substring(2, 5); const chainIdDecimal = parseInt(chainId.split(':')[1], 10); - const chainIdHex = numberToHex(chainIdDecimal); - const resolvedDomain = `example.domain - ${shortAddress} / ${chainIdHex}`; + const resolvedDomain = `${shortAddress}.${chainIdDecimal}.test.domain`; return { resolvedDomain }; } diff --git a/packages/snaps-controllers/package.json b/packages/snaps-controllers/package.json index d7c700b04a..3ad2fccbea 100644 --- a/packages/snaps-controllers/package.json +++ b/packages/snaps-controllers/package.json @@ -49,8 +49,7 @@ "@metamask/permission-controller": "^4.1.2", "@metamask/post-message-stream": "^7.0.0", "@metamask/rpc-methods": "workspace:^", - "@metamask/snaps-execution-environments": "workspace:^", - "@metamask/snaps-registry": "^2.0.0", + "@metamask/snaps-registry": "^2.1.0", "@metamask/snaps-utils": "workspace:^", "@metamask/utils": "^8.1.0", "@xstate/fsm": "^2.0.0", @@ -62,7 +61,7 @@ "json-rpc-middleware-stream": "^4.2.0", "nanoid": "^3.1.31", "readable-web-to-node-stream": "^3.0.2", - "tar-stream": "^2.2.0" + "tar-stream": "^3.1.6" }, "devDependencies": { "@esbuild-plugins/node-globals-polyfill": "^0.2.3", @@ -84,7 +83,7 @@ "@types/mocha": "^10.0.1", "@types/node": "18.14.2", "@types/readable-stream": "^2.3.15", - "@types/tar-stream": "^2.2.2", + "@types/tar-stream": "^3.1.1", "@typescript-eslint/eslint-plugin": "^5.42.1", "@typescript-eslint/parser": "^5.42.1", "@wdio/browser-runner": "^8.15.9", @@ -122,6 +121,14 @@ "wdio-geckodriver-service": "^5.0.2", "webdriverio": "^8.15.9" }, + "peerDependencies": { + "@metamask/snaps-execution-environments": "workspace:^" + }, + "peerDependenciesMeta": { + "@metamask/snaps-execution-environments": { + "optional": true + } + }, "engines": { "node": "^18.16 || >=20" }, diff --git a/packages/snaps-controllers/src/cronjob/CronjobController.ts b/packages/snaps-controllers/src/cronjob/CronjobController.ts index e8f4ddd46a..a75b27ff80 100644 --- a/packages/snaps-controllers/src/cronjob/CronjobController.ts +++ b/packages/snaps-controllers/src/cronjob/CronjobController.ts @@ -289,7 +289,7 @@ export class CronjobController extends BaseController< /** * Runs every 24 hours to check if new jobs need to be scheduled. * - * This is necesary for longer running jobs that execute with more than 24 hours between them. + * This is necessary for longer running jobs that execute with more than 24 hours between them. */ async dailyCheckIn() { const jobs = this.getAllJobs(); diff --git a/packages/snaps-controllers/src/snaps/SnapController.ts b/packages/snaps-controllers/src/snaps/SnapController.ts index 86eecb3f8d..88e7ad6b79 100644 --- a/packages/snaps-controllers/src/snaps/SnapController.ts +++ b/packages/snaps-controllers/src/snaps/SnapController.ts @@ -1777,7 +1777,7 @@ export class SnapController extends BaseController< // Since we are requesting an update from within processRequestedSnap, // we disable the emitting of the snapUpdated event and rely on the caller // to publish this event after the update is complete. - // This is necesary as installSnaps may be installing multiple snaps + // This is necessary as installSnaps may be installing multiple snaps // and we don't want to emit events prematurely. false, ); diff --git a/packages/snaps-controllers/wdio.config.js b/packages/snaps-controllers/wdio.config.js index ae2aedaf17..3f159c6f0e 100644 --- a/packages/snaps-controllers/wdio.config.js +++ b/packages/snaps-controllers/wdio.config.js @@ -1,4 +1,4 @@ -/* eslint-disable import/unambiguous, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ +/* eslint-disable import/unambiguous, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, n/no-process-env */ const { NodeGlobalsPolyfillPlugin, @@ -9,9 +9,10 @@ const { const { resolve } = require('path'); const { default: tsconfigPaths } = require('vite-tsconfig-paths'); -// eslint-disable-next-line n/no-process-env const IS_CI = Boolean(process.env.CI); -const MAX_WORKERS = IS_CI ? 1 : 5; +const MAX_WORKERS = process.env.MAX_WORKERS + ? parseInt(process.env.MAX_WORKERS, 10) + : 1; const config = { runner: [ @@ -56,10 +57,14 @@ const config = { maxInstances: MAX_WORKERS, browserName: 'chrome', }, - { - maxInstances: MAX_WORKERS, - browserName: 'firefox', - }, + ...(IS_CI + ? [ + { + maxInstances: MAX_WORKERS, + browserName: 'firefox', + }, + ] + : []), ], logLevel: 'error', diff --git a/packages/snaps-execution-environments/wdio.config.js b/packages/snaps-execution-environments/wdio.config.js index a05eefec51..d809967292 100644 --- a/packages/snaps-execution-environments/wdio.config.js +++ b/packages/snaps-execution-environments/wdio.config.js @@ -1,4 +1,4 @@ -/* eslint-disable import/unambiguous, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ +/* eslint-disable import/unambiguous, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, n/no-process-env */ const { NodeGlobalsPolyfillPlugin, @@ -9,9 +9,10 @@ const { const { resolve } = require('path'); const { default: tsconfigPaths } = require('vite-tsconfig-paths'); -// eslint-disable-next-line n/no-process-env const IS_CI = Boolean(process.env.CI); -const MAX_WORKERS = IS_CI ? 1 : 5; +const MAX_WORKERS = process.env.MAX_WORKERS + ? parseInt(process.env.MAX_WORKERS, 10) + : 1; const config = { runner: [ @@ -55,10 +56,14 @@ const config = { maxInstances: MAX_WORKERS, browserName: 'chrome', }, - { - maxInstances: MAX_WORKERS, - browserName: 'firefox', - }, + ...(IS_CI + ? [ + { + maxInstances: MAX_WORKERS, + browserName: 'firefox', + }, + ] + : []), ], logLevel: 'error', diff --git a/packages/snaps-utils/package.json b/packages/snaps-utils/package.json index c2638ab8a0..3646f7de98 100644 --- a/packages/snaps-utils/package.json +++ b/packages/snaps-utils/package.json @@ -71,7 +71,7 @@ "@metamask/base-controller": "^3.2.0", "@metamask/key-tree": "^9.0.0", "@metamask/permission-controller": "^4.1.2", - "@metamask/snaps-registry": "^2.0.0", + "@metamask/snaps-registry": "^2.1.0", "@metamask/snaps-ui": "workspace:^", "@metamask/utils": "^8.1.0", "@noble/hashes": "^1.3.1", diff --git a/packages/snaps-utils/wdio.config.js b/packages/snaps-utils/wdio.config.js index caa5a516bd..0d30f0031e 100644 --- a/packages/snaps-utils/wdio.config.js +++ b/packages/snaps-utils/wdio.config.js @@ -1,4 +1,4 @@ -/* eslint-disable import/unambiguous, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ +/* eslint-disable import/unambiguous, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, n/no-process-env */ const { NodeGlobalsPolyfillPlugin, @@ -9,9 +9,10 @@ const { const { resolve } = require('path'); const { default: tsconfigPaths } = require('vite-tsconfig-paths'); -// eslint-disable-next-line n/no-process-env const IS_CI = Boolean(process.env.CI); -const MAX_WORKERS = IS_CI ? 1 : 5; +const MAX_WORKERS = process.env.MAX_WORKERS + ? parseInt(process.env.MAX_WORKERS, 10) + : 1; const config = { runner: [ @@ -55,10 +56,14 @@ const config = { maxInstances: MAX_WORKERS, browserName: 'chrome', }, - { - maxInstances: MAX_WORKERS, - browserName: 'firefox', - }, + ...(IS_CI + ? [ + { + maxInstances: MAX_WORKERS, + browserName: 'firefox', + }, + ] + : []), ], logLevel: 'error', diff --git a/yarn.lock b/yarn.lock index 1aa966deca..98eb80e0c3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4711,7 +4711,6 @@ __metadata: "@metamask/snaps-cli": "workspace:^" "@metamask/snaps-jest": "workspace:^" "@metamask/snaps-types": "workspace:^" - "@metamask/utils": ^8.1.0 "@swc/core": 1.3.78 "@swc/jest": ^0.2.26 "@typescript-eslint/eslint-plugin": ^5.42.1 @@ -5149,8 +5148,7 @@ __metadata: "@metamask/permission-controller": ^4.1.2 "@metamask/post-message-stream": ^7.0.0 "@metamask/rpc-methods": "workspace:^" - "@metamask/snaps-execution-environments": "workspace:^" - "@metamask/snaps-registry": ^2.0.0 + "@metamask/snaps-registry": ^2.1.0 "@metamask/snaps-utils": "workspace:^" "@metamask/template-snap": ^0.7.0 "@metamask/utils": ^8.1.0 @@ -5164,7 +5162,7 @@ __metadata: "@types/mocha": ^10.0.1 "@types/node": 18.14.2 "@types/readable-stream": ^2.3.15 - "@types/tar-stream": ^2.2.2 + "@types/tar-stream": ^3.1.1 "@typescript-eslint/eslint-plugin": ^5.42.1 "@typescript-eslint/parser": ^5.42.1 "@wdio/browser-runner": ^8.15.9 @@ -5203,7 +5201,7 @@ __metadata: prettier-plugin-packagejson: ^2.2.11 readable-web-to-node-stream: ^3.0.2 rimraf: ^4.1.2 - tar-stream: ^2.2.0 + tar-stream: ^3.1.6 ts-node: ^10.9.1 typescript: ~4.8.4 vite: ^4.3.9 @@ -5211,6 +5209,11 @@ __metadata: wdio-chromedriver-service: ^8.1.1 wdio-geckodriver-service: ^5.0.2 webdriverio: ^8.15.9 + peerDependencies: + "@metamask/snaps-execution-environments": "workspace:^" + peerDependenciesMeta: + "@metamask/snaps-execution-environments": + optional: true languageName: unknown linkType: soft @@ -5347,14 +5350,14 @@ __metadata: languageName: unknown linkType: soft -"@metamask/snaps-registry@npm:^2.0.0": - version: 2.0.0 - resolution: "@metamask/snaps-registry@npm:2.0.0" +"@metamask/snaps-registry@npm:^2.1.0": + version: 2.1.0 + resolution: "@metamask/snaps-registry@npm:2.1.0" dependencies: "@metamask/utils": ^8.1.0 "@noble/secp256k1": ^1.7.1 superstruct: ^1.0.3 - checksum: 621baf98c53c490d4bf8bf784910943e3c147cc2abdbcf5ea56ae6fcd45a1a412da79b0ef778b8f9d8c46b9272068d3dd5909be6691579590d2632c6baee8992 + checksum: 652e8c5cc0be43325ba6cf9382db982380f34d1710bfbcc27c9d58cf0e0c14bd354e112b2feb27c1ca7264a0793795d9020a4315ffcf10fa6fed8f38cf18fcde languageName: node linkType: hard @@ -5593,7 +5596,7 @@ __metadata: "@metamask/key-tree": ^9.0.0 "@metamask/permission-controller": ^4.1.2 "@metamask/post-message-stream": ^7.0.0 - "@metamask/snaps-registry": ^2.0.0 + "@metamask/snaps-registry": ^2.1.0 "@metamask/snaps-ui": "workspace:^" "@metamask/utils": ^8.1.0 "@noble/hashes": ^1.3.1 @@ -7510,12 +7513,12 @@ __metadata: languageName: node linkType: hard -"@types/tar-stream@npm:^2.2.2": - version: 2.2.2 - resolution: "@types/tar-stream@npm:2.2.2" +"@types/tar-stream@npm:^3.1.1": + version: 3.1.1 + resolution: "@types/tar-stream@npm:3.1.1" dependencies: "@types/node": "*" - checksum: 4b33bc0d53770e952d6e2e8acb8889190510326a3e255d0c6edd94136d6027ecae939a7b49188d1d02d774328d9a3742ff633d505709d1a1200b3413c88d793d + checksum: ba9e5c3bc31a4eefe2c519d06bd9f563d1ddadb83ea272d23390276aeeda4766cb74ba5217a765994a65c86bdf0ba41fa731633c0b3dc63e6c4d959f4672cf86 languageName: node linkType: hard @@ -21541,7 +21544,7 @@ __metadata: languageName: node linkType: hard -"tar-stream@npm:^3.1.5": +"tar-stream@npm:^3.1.5, tar-stream@npm:^3.1.6": version: 3.1.6 resolution: "tar-stream@npm:3.1.6" dependencies: