From 9bcaa1bfa8c565c4b6bff12c6bb39985eff21f6c Mon Sep 17 00:00:00 2001 From: Hassan Malik <41640681+hmalik88@users.noreply.github.com> Date: Wed, 11 Oct 2023 14:51:44 -0400 Subject: [PATCH 1/6] Fix name lookup example snap (#1838) The current example snap is not inline with SIP-12, see https://github.com/MetaMask/snaps/pull/1768#discussion_r1334399505 --- packages/examples/packages/name-lookup/package.json | 3 +-- packages/examples/packages/name-lookup/snap.manifest.json | 2 +- packages/examples/packages/name-lookup/src/index.test.ts | 4 ++-- packages/examples/packages/name-lookup/src/index.ts | 6 ++---- yarn.lock | 1 - 5 files changed, 6 insertions(+), 10 deletions(-) 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/yarn.lock b/yarn.lock index 225e2a0b4e..4f3d56b03e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4673,7 +4673,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 From 03f81c0dc363a3c9541c154c726508c90e0d3ee3 Mon Sep 17 00:00:00 2001 From: Frederik Bolding Date: Thu, 12 Oct 2023 13:52:54 +0200 Subject: [PATCH 2/6] Make `snaps-execution-environments` an optional peer dependency (#1845) Makes `snaps-execution-environments` an optional peer dependency since you only need the dependency if you are trying to use the Node.js environments. Fixes #1844 --- packages/snaps-controllers/package.json | 9 ++++++++- yarn.lock | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/snaps-controllers/package.json b/packages/snaps-controllers/package.json index d7c700b04a..6d300f2351 100644 --- a/packages/snaps-controllers/package.json +++ b/packages/snaps-controllers/package.json @@ -49,7 +49,6 @@ "@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-utils": "workspace:^", "@metamask/utils": "^8.1.0", @@ -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/yarn.lock b/yarn.lock index 4f3d56b03e..be66d9369b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5110,7 +5110,6 @@ __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-utils": "workspace:^" "@metamask/template-snap": ^0.7.0 @@ -5172,6 +5171,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 From 1154c5cbd72fa0bbcdf8f1b33ff156ac9dc7ca79 Mon Sep 17 00:00:00 2001 From: Frederik Bolding Date: Thu, 12 Oct 2023 14:16:59 +0200 Subject: [PATCH 3/6] Tweak WDIO config (#1840) Tweaks the WDIO config, reducing the number of workers to 1 and disables running tests in FF locally. --- packages/snaps-controllers/wdio.config.js | 19 ++++++++++++------- .../wdio.config.js | 19 ++++++++++++------- packages/snaps-utils/wdio.config.js | 19 ++++++++++++------- 3 files changed, 36 insertions(+), 21 deletions(-) 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/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', From a505515c8653e93bd10b91837174cad89e598bdf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Oct 2023 14:43:49 +0200 Subject: [PATCH 4/6] Bump @metamask/snaps-registry from 2.0.0 to 2.1.0 (#1846) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [@metamask/snaps-registry](https://github.com/MetaMask/snaps-registry) from 2.0.0 to 2.1.0.
Release notes

Sourced from @​metamask/snaps-registry's releases.

2.1.0

Added

  • Add hidden field to metadata (#226)
Changelog

Sourced from @​metamask/snaps-registry's changelog.

[2.1.0]

Added

  • Add hidden field to metadata (#226)
Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=@metamask/snaps-registry&package-manager=npm_and_yarn&previous-version=2.0.0&new-version=2.1.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Frederik Bolding --- packages/snaps-controllers/package.json | 2 +- packages/snaps-utils/package.json | 2 +- yarn.lock | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/snaps-controllers/package.json b/packages/snaps-controllers/package.json index 6d300f2351..6428e50d4a 100644 --- a/packages/snaps-controllers/package.json +++ b/packages/snaps-controllers/package.json @@ -49,7 +49,7 @@ "@metamask/permission-controller": "^4.1.2", "@metamask/post-message-stream": "^7.0.0", "@metamask/rpc-methods": "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", 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/yarn.lock b/yarn.lock index be66d9369b..48d1b06dba 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5110,7 +5110,7 @@ __metadata: "@metamask/permission-controller": ^4.1.2 "@metamask/post-message-stream": ^7.0.0 "@metamask/rpc-methods": "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 @@ -5312,14 +5312,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 @@ -5558,7 +5558,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 From cffc3c3c9963674b355d325926f93ff22acca830 Mon Sep 17 00:00:00 2001 From: GoodDaisy <90915921+GoodDaisy@users.noreply.github.com> Date: Fri, 13 Oct 2023 17:26:53 +0800 Subject: [PATCH 5/6] Fix documentation typos (#1847) --- packages/snaps-controllers/src/cronjob/CronjobController.ts | 2 +- packages/snaps-controllers/src/snaps/SnapController.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 4a13728e2e..a17f354120 100644 --- a/packages/snaps-controllers/src/snaps/SnapController.ts +++ b/packages/snaps-controllers/src/snaps/SnapController.ts @@ -1739,7 +1739,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, ); From d98032b3c7a672160c2495e002099dc0d7a0fbeb Mon Sep 17 00:00:00 2001 From: Frederik Bolding Date: Fri, 13 Oct 2023 12:15:20 +0200 Subject: [PATCH 6/6] Bump `tar-stream` to the latest version (#1853) We were using a really old version, this brings us up to date with a more recent version. --- packages/snaps-controllers/package.json | 4 ++-- yarn.lock | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/snaps-controllers/package.json b/packages/snaps-controllers/package.json index 6428e50d4a..3ad2fccbea 100644 --- a/packages/snaps-controllers/package.json +++ b/packages/snaps-controllers/package.json @@ -61,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", @@ -83,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", diff --git a/yarn.lock b/yarn.lock index 48d1b06dba..57e84a6bf9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5124,7 +5124,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 @@ -5163,7 +5163,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 @@ -7475,12 +7475,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 @@ -21506,7 +21506,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: